|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Disabling /Enabling multiple form fields
Hi,
I'm trying to enable a number of form fields by selecting a specific checkbox. I can successfully enable the fields but I can't "Re-disable" them. I have the fields set to disabled as their default. Here's the code: <script> function Disab (val) { if(val="nailcbox.checked.yes") {form.nailstyle[0].disabled=false; form.nailstyle[1].disabled=false; form.nailstyle[2].disabled=false; form.nailheadsize.disabled=false; form.arm.disabled=false; form.back.disabled=false; form.base.disabled=false} else {form.nailstyle[0].disabled=false; form.nailstyle[1].disabled=false; form.nailstyle[2].disabled=false; form.nailheadsize.disabled=false; form.arm.disabled=false; form.back.disabled=false; form.base.disabled=false} } </script> What am I missing? Thanks in advance Pier |
|
#2
|
||||
|
||||
|
Could it have something to do with the fact that in both your if and your else, you're setting the fields to false?
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Still not working but thanks....
I think that was a result of me changing it a million times to see if something would work.
I changed the second set of falses to true and it still didn't work. Any other ideas? And thanks for your fast response. |
|
#4
|
|||
|
|||
|
U r using same script in both if and else culse.
U should do this: function Disab (val) { if(val="nailcbox.checked.yes") {form.nailstyle[0].disabled=false; form.nailstyle[1].disabled=false; form.nailstyle[2].disabled=false; form.nailheadsize.disabled=false; form.arm.disabled=false; form.back.disabled=false; form.base.disabled=false; } else {form.nailstyle[0].disabled=true; form.nailstyle[1].disabled=true; form.nailstyle[2].disabled=true; form.nailheadsize.disabled=true; form.arm.disabled=true; form.back.disabled=true; form.base.disabled=true; } } </script> Burhan |
|
#5
|
|||
|
|||
|
Still having trouble....
I tried that and it will enable the form fields but when I re-click the checkbox, I want them to become diabled again. That's the part that's still not working. Could it have something to do with the fact that the form fields are disabled?
Example: <INPUT type="checkbox" id="nailcbox" name="nailheads" value="nailheads" onClick="Disab()" unchecked>nailheads <br> <select name="nailheadsize" disabled> <option value="">-Choose Size- <option value="Small">Small <option value="Medium">Medium <option value="Large">Large <option value="Custom">Custom </select> <br><br> Nailhead Location:<br> <INPUT type="checkbox" name="arm" value="arm," disabled>arm <INPUT type="checkbox" name="back" value="back," disabled>back <INPUT type="checkbox" name="base" value="base" disabled>base I'm totally confused. This seems like it should work. |
|
#6
|
|||
|
|||
|
Quote:
Please post your error message, that u encountered. Burhan |
|
#7
|
|||
|
|||
|
No error message
I don't get an error message. It's weird. The only thing that re-disables the fields is when I reload / refresh the page.
|
|
#8
|
|||
|
|||
|
Sulotion is:
<script> function Disab () { // no parameter in the Disab function if(form.nailcbox.checked) { form.nailheadsize.disabled=false; form.arm.disabled=false; form.back.disabled=false; form.base.disabled=false; } else { form.nailheadsize.disabled=true; form.arm.disabled=true; form.back.disabled=true; form.base.disabled=true; } } </script> Only replace your script with this one and tell me about this. Burhan |
|
#9
|
|||
|
|||
|
You are a genius
It worked. Thanks alot.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Disabling /Enabling multiple form fields |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|