Pls, to all in General, I nid a Simple Javascript func or code that Can Pops Up a text box if a particular option is selected in a drop down menu of an html form tag..
I.e
How Do you Want Us to Reach You?
Via:
<select name='contact'><option value='SMS'>SMS</option><option value='Email'>Email</option><option value='Web'>Web</option></select>

So, i want a textbox to be pops out individualy for evry selected option

ie <input type="text" name="sms"> to b Pops out if dem select sms method

<input type="text" name="email"> to b Pops out if dem select email method
and
<input type="text" name="web">
to b Pops out if dem select web method

thanks yet... Any Help rendered would b appreciated!

Download Now
  • Date: Nov 28, 2013

Y naijagoody.com is like netnaija.com ? Or did you people sale de script 4 him ?

  • Date: Nov 28, 2013


Y naijagoody.com is like netnaija.com ? Or did you people sale de script 4 him ?

matthew32

No o o... the Only tin i notice abt Gerardcole na Uniquenex and creativity.. I beliv na Source code.. It can neva b as efficient as this web.. Shine ur eyes and surf it wella.. Nt same bro

  • Date: Nov 28, 2013


Do you mean pop out or display itself?

Gerardcole

display itself bro.. Wen a particular option is selected.. Dis kind onclick of a tinx.. Thanks bro

  • Date: Nov 28, 2013


Okay. Later at night I'll try something.

Do you need it in JavaScript or jQuery

Gerardcole

Oga mi... Anyone.. Gat no Choice.. Just help me Out

  • Date: Feb 19, 2014


Okay. Later at night I'll try something.

Do you need it in JavaScript or jQuery

Gerardcole

Bro am still patiently waiting bro

  • Date: Feb 21, 2014
  • Edited: Mar 19, 2014 by Gerardcole

After the <select>...</select>, you'll need to add a textbox with the name attribute empty, give it a unique id like myTextBox and make it invisible using CSS. E.g.

HTML Code
<input type="text" name="" id="myTextBox" style="display:none">

Meanwhile make sure the <select> has its own unique id. This snippet focuses on using selectMenu. i.e

HTML Code
<select id="selectMenu">...</select>

After you might have included the jquery library.

Add this code..

JavaScript Code
<script>
    $(document).ready(function(){
        $("#selectMenu").change(function(){
            var selected = $("#selectMenu option:selected").val(); //gets the value the user selected.
            $("#myTextBox").attr("name", selected); //sets the name of the textbox to the value of the option selected
            $("#myTextBox").show(); //Shows the textbox.
        });
    };
</script>

that should solve your prob.

  • Date: Feb 22, 2014

Thanks... I really appreciate this help... Have even twisted it and its working as expected