I am trying to get a link that when clicked it will check all the checkboxes in my form.
My problem is that my values are stored in an array:
<INPUT TYPE=\"checkbox\" name=\"emailArray[]\" value=\"$email\">
print"<br><a href=\"#\" onClick=\"checkAll()\">check all</a><br>";
Here is my javascript function :
function checkAll(){
alert('hi');
var df = document.selectEmailForm.elements;
for (var i = 0; i < df.length; i++) {
if (df[i].name == "emailArray[]" ) {
document.selectEmailForm.emailArray[i].checked=true;
}
}
}
Any ideas? Any help is greatly appreciated.
Thanks for your time!
My problem is that my values are stored in an array:
<INPUT TYPE=\"checkbox\" name=\"emailArray[]\" value=\"$email\">
print"<br><a href=\"#\" onClick=\"checkAll()\">check all</a><br>";
Here is my javascript function :
function checkAll(){
alert('hi');
var df = document.selectEmailForm.elements;
for (var i = 0; i < df.length; i++) {
if (df[i].name == "emailArray[]" ) {
document.selectEmailForm.emailArray[i].checked=true;
}
}
}
Any ideas? Any help is greatly appreciated.
Thanks for your time!
Comment