Results 1 to 2 of 2
Jul 27, 2008, 14:14 #1
- Join Date
- Feb 2004
- 0 Post(s)
- 0 Thread(s)
How to dynamically disable form elements
I'm trying to dynamicly disable certain form elements after a user selects a checkbox on a form. My form that is loaded is populated with dynamic elements, and the elements that need to be disabled will also be dynamic. As such, I've populated an array with the elements that are valid to potentially be disabled. When a user selects a checkbox, I call a function to determine if the OTHER form checkboxes should be disabled or not. The problem that I'm having is that I can't figure out how to dynamicly disable those elements.
For instance, if I have a checkbox named "bike" that needs to be disabled, then I can input this, and it will work fine:
However, if I populate an array, and substitute "bike" for it's position in the array, it doesn't work. Something like this is what I need:
I've simplified the code here but this is the gist of what needs to happen. The array is working properly and if I print the data to screen from that function it is correct.The "formElements" will actually need to be something like "formElements[i]" given that it will be nested in an if statement checking to see where the form element should be disabled or not.
Thank in advance for your help.
Jul 27, 2008, 14:28 #2
- Join Date
- Sep 2005
- Sydney, NSW, Australia
- 25 Post(s)
- 1 Thread(s)