|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using a checkbox to enable SELECT field?
Hi!
In my lack of javascript knowlengde, i have to ask... How can i get a select box to be disabled by default, and enabled when i hit the checkbox? Ive got this.. (found it at this board) <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> <!-- function disableText() { document.form1.expired.disabled=true; return; } --> </script> </head> <body> <form name="form1"> <p> <input type="checkbox" name="checkbox" value="checkbox" onFocus="return disableText();"> </p> <p> <SELECT NAME="expired"> <OPTION SELECTED VALUE="01">jan <OPTION VALUE="02">feb <OPTION VALUE="03">mar </SELECT> </form> </p> <p><li>When page loads, the select boxes are disabled by default?</p> <p><li>When you hit the checkbox, you enable the selectboxes?</p> <p><li>When you hit the checkbox again, the selectboxes are disabled?</p> </body> </html> |
|
#2
|
|||
|
|||
|
RE: Using a checkbox to enable SELECT field?
Here is the modified code to do what you want.
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> <!-- function disableText() { if(document.form1.checkbox.checked){ document.form1.expired.disabled=false; }else{ document.form1.expired.disabled=true; } } --> </script> </head> <body> <form name="form1"> <p> <input type="checkbox" name="checkbox" value="checkbox" onclick="disableText();"> </p> <p> <SELECT NAME="expired" disabled> <OPTION SELECTED VALUE="01">jan <OPTION VALUE="02">feb <OPTION VALUE="03">mar </SELECT> </form> </p> <p><li>When page loads, the select boxes are disabled by default?</p> <p><li>When you hit the checkbox, you enable the selectboxes?</p> <p><li>When you hit the checkbox again, the selectboxes are disabled?</p> </body> </html> |
|
#3
|
|||
|
|||
|
RE: Using a checkbox to enable SELECT field?
Thank you!! Wow! Great!!
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Using a checkbox to enable SELECT field? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|