reaching the edge of my JS chops on this particular problem. am convinced the events i'm stringing onto the onclick is better performed with script up in the head. but dont know the How.
GOAL
I have a page with multiple form elements, each with unique IDs.
On load, some of the elements are disabled, rest are enabled.
Using a single onclick of a checkbox, disable a list of elements as well as enable a list of others.
Unticking the checkbox causes the form elements to return to previous states.
PROBLEM SUMMARY
I am using getElementById, but trying to call a list of >1 ID.
When page loads, the checkbox does work, but only on the first ID in the string.
If there's a way to string >1 onto getElementById, it would suffice; my final page will have state changes on only 4-5 elements.
However, if there was a more efficient way to do this, using a function in the head, i'd like an example so i can study and modify.
Thanks...
SAMPLE PAGE
HTML Code:
<form name="form1" action="#" method="post">
<input type="checkbox" id="checkmain1" onclick="if(this.checked) {getElementById('text2','select2','check2').disabled=false;getElementById('text1','select1','check1').disabled=true;}else{getElementById('text2','select2','check2').disabled=true;getElementById('text1','select1','check1').disabled=false;}" /><label for="checkmain1">Enable/Disable</label><br />
<p>
All elements in this row should get DISabled:
<input type="text" id="text1" value="disabled by checkbox" />
<select id="select1">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="checkbox" id="check1" /><label for="check1">check 1</label>
</p>
<p>
All elements in this row should get ENabled:
<input type="text" id="text2" value="enabled by checkbox" disabled="disabled" />
<select id="select2" disabled="disabled">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="checkbox" id="check2" disabled="disabled" /><label for="check2">check 2</label>
</p>
</form>