Changing Checkbox Names
I'm setting up a Javascript that checks or unchecks all. The script I have looks for all the form elements with the same name. So I want my checkboxes to end up in html like this:
<input id="chkBox1" type="checkbox" name="chkBoxes" onclick="checkOrUncheck('chkBox1')" />
<input id="chkBox2" type="checkbox" name="chkBoxes" onclick="checkOrUncheck('chkBox2')" />
<input id="chkBox3" type="checkbox" name="chkBoxes" onclick="checkOrUncheck('chkBox3')" />
However, I keep getting:
<input id="chkBox1" type="checkbox" name="chkBox1" onclick="checkOrUncheck('chkBox1')" />
<input id="chkBox2" type="checkbox" name="chkBox2" onclick="checkOrUncheck('chkBox2')" />
<input id="chkBox3" type="checkbox" name="chkBox3" onclick="checkOrUncheck('chkBox3')" />
The name attribute is the same as the id. In the code behind I've added
chkBox.Attribute["name"] = "chkboxes";
which produced:
<SPAN Name="chkboxes">
<input id="chkBox1" type="checkbox" name="chkBox1" onclick="checkOrUncheck('chkBox1')" /></SPAN>
<input id="chkBox2" type="checkbox" name="chkBox2" onclick="checkOrUncheck('chkBox2')" /></SPAN>
<input id="chkBox3" type="checkbox" name="chkBox3" onclick="checkOrUncheck('chkBox3')" /></SPAN>
I tried:
chkBox.Attribute["name"].Replace(chkBox.ID, "chkBoxes);
which didn't render the page at all.
How do I get the name attribute to change?
PRD
|