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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -