Lets say I have this dropdown: select name="tab"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select> How could I make another dropdown appear in a certain place if "yes" is selected in the first one (it should disappear if it's changed back to "no"). Any advice?
I think this will help you <html> <head> <title>Dropdown Appear</title> <script type="text/javascript"> function dropdown_appear(){ if(document.getElementById("tab").value=="yes"){ document.getElementById("another_dropdown_div").style.display = ""; }else{ document.getElementById("another_dropdown_div").style.display = "none"; } } </script> </head> <body> <select name="tab" id="tab" onchange="dropdown_appear();"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select> <div id="another_dropdown_div" style="display: none"> <select name="another_dropdown" id="another_dropdown"> <option value="option1">Option1</option> <option value="option2">Option2</option> <option value="option3">Option3</option> </select> </div> </body> </html> Code (markup):
Thanks. Can I add more stuff between the div tags to be hidden? I tried adding a table row but that didn't work...
<tr> <td>Do this: <br /> <br /></td> <td><select name="dissolve" id="dissolve" onchange="dropdown_appear();"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select></td> </tr> <div id="delun_div" style="display: none"> <tr> <td align="left">Do this too:</td> <td align="left"> <select name="delun" id="delun"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select> </td> </tr> </div> Code (markup): Only the value names are changed. It works perfectly when I leave the <tr>and <td> out from the div tags.
Try so <tr> <td>Do this: <br /> <br /></td> <td><select name="dissolve" id="dissolve" onchange="dropdown_appear();"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select></td> </tr> <tr id="delun_div" style="display: none"> <td align="left">Do this too:</td> <td align="left"> <select name="delun" id="delun"> <option selected="selected" value="no">no</option> <option value="yes">yes</option> </select> </td> </tr> Code (markup):