I have a DropDownList that asks the user if he wants to join the club:
Do you want to join the club Yes No
There is another list in this list, which is disabled by default. There are club departments on this list. This list will not be included until the user selects "Yes."
I built the following code, but a problem that I could not solve suggests that the user selects Yes, then he changes his mind, so he will not select "No" again. In this case, the list of departments is still included. I want it to be disabled when it again selects "No".
<html> <head> <script type="text/javascript"> function disable() { document.getElementById("mySelect1").disabled=true; } function enable() { document.getElementById("mySelect1").disabled=false; } </script> </head> <body> <form> <select id="mySelect" onChange="enable();"> <option onSelect="disable();">No</option> <option onSelect="enable();">Yes</option> </select> <select id="mySelect1" disabled="disabled" > <option>Dep1</option> <option>Dep2</option> <option>Dep3</option> <option>Dep4</option> </select> </form> </body> </html>
I thought onSelect="disable();" will solve the problem, but still does not work.
thanks
Nasser
source share