Ok, I am working on a sleek Contact Us page and I want to be able to have the "other" option be selectable and people can enter their own subject. Well to do this I want to make it so if you select the "other" option in the drop down menu in a text box will show up below it. So far I got everything else done on the drop down menu except that.
A simple example how you can do it: <html> <head> <title>Example</title> </head> <script type="text/javascript"> function changed(){ if(document.getElementById("dropdown").value=="other"){ the_textbox = document.createElement("textarea"); the_textbox.id = "own_subject"; the_textbox.name = "own_subject"; document.getElementById("textbox").appendChild(the_textbox); }else{ if(document.getElementById("own_subject")){ document.getElementById("textbox").removeChild(document.getElementById("own_subject")); } } } </script> <body> <select id="dropdown" onchange="changed();"> <option value="this">This</option> <option value="other">Other</option> </select> <div id="textbox"></div> </body> </html> Code (JavaScript):
Wow thank you so much. This will really liven up my contact us page. I seriously need to learn javascript myself.