jasonc Posted August 18, 2010 Share Posted August 18, 2010 How can I get the form to un-disable the second field if the first selection made is 'other' but if another selection is made then the field stays disbled. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" method="post" action=""> <select name="select"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="other">other</option> </select> <br> <br> <input type="text" name="textfield"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
jasonc Posted August 18, 2010 Author Share Posted August 18, 2010 UPDATED: but still not changing the next field to un-disabled. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> <!-- function check_select(form, selection, other) { var theform = document.getElementById(form); var theselection = theform.selection.value; if ((theselection == "other")) { theselection.disabled = false; } else { theselection.disabled = true; } } --> </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <select name="selection" onChange="check_select('form1', 'selection', 'other')"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="other">other</option> </select> <br> <br> <input id="other" type="text" name="other" disabled> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
radar Posted August 18, 2010 Share Posted August 18, 2010 onChange="check_select(); return false" function check_select() { id = document.form1.elements["selection"].selectedIndex; vel = document.form1.options[id].value if (vel == other) { document.getElementByID['textbox'].disabled = false; } else { document.getElementByID['textbox'].disabled = true; } } something like that could work.. though it's not tested. 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.