MDanz Posted June 27, 2010 Share Posted June 27, 2010 Need help doing this. On a drop down list, onclick of an option an input textfield appears. e.g. echo "<select> <option>What is your opinion on</option> </select>"; echo "<div id='pop'><input type='hidden' id='opinion' size='20' name='opinion' value='Type Keyword Here' /></div>"; i want it to be hidden and then appear onclick of the option in the dropdown list... How do i do this? Quote Link to comment Share on other sites More sharing options...
xenophobia Posted June 28, 2010 Share Posted June 28, 2010 Suppose you got a select element: <select onchange="optionChanged(this);"> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> <option value="0">Other</option> </select> And a input box: <input type="text" id="txtBox" size="30" style="display: none;" /> Now, put these codes in your header: <script language="JavaScript" type="text/javascript"> function optionChanged(ele) { var val = ele.options[ele.options.selectedIndex].value; if (val == 0) { document.getElementById("txtBox").style.display = "block"; } } </script> So when you select Other, the textbox will appear. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.