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? Link to comment https://forums.phpfreaks.com/topic/206008-drop-down-list-onclick/ 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. Link to comment https://forums.phpfreaks.com/topic/206008-drop-down-list-onclick/#findComment-1078222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.