...

View Full Version : Enable/disable/visible/hide textboxes based on option selected in selected tag



hbmarar
03-22-2005, 10:16 AM
I need to make a textbox visible and another hidden if a particular option is selected.Though I have a little bit idea I am not getting to anywhere.I request the forum members to help me out.

Thanking in advance

glenngv
03-22-2005, 10:34 AM
function hideShowFields(oSel){
var oFrm = oSel.form;
switch (oSel.options[oSel.selectedIndex].value){
case "red":
oFrm.fieldToShow.style.display='inline';
oFrm.fieldToHide.style.display='none';
break;
//...other cases
}
}
...
<select onchange="hideShowFields(this)">
<option value="blue">Blue</option>
<option value="red">Red</option>
...
</select>
<input type="text" name="fieldToShow" style="display:none" value="hello" />
<input type="text" name="fieldToHide" style="display:inline" value="world" />



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum