Show Input Text After Choose Combobox -
i have question how show text field based on choose combobox. have code :
<select name="comment"> <option value="">choose one</option> <option value="good">good</option> <option value="others">others</option> </select>
if choose others, want text input show.
how can ? can done without jquery ?
using plain javascript, try this
html portion
<select name="comment" id="combo" onchange="check();"> <option value="">choose one</option> <option value="good">good</option> <option value="others">others</option> </select> <input type = "text" id ="dummytext" visible="false" style="visibility:hidden"/>
javascript portion
function check() { var el = document.getelementbyid("combo"); var str = el.options[el.selectedindex].text; if(str == "others") { show(); }else { hide(); } } function hide(){ document.getelementbyid('dummytext').style.visibility='hidden'; } function show(){ document.getelementbyid('dummytext').style.visibility='visible'; }
check jsfiddle
Comments
Post a Comment