I have this bit of javascript which toggles all checkboxes to checked onclick but it only works if the form has a name.
I use XHTML strict and to validate it, it fails becuase there is no attribute name in a form.
How can i get this to work by taking out the name from the form and just keep my id?
checked=false;
function checkAll (adminform) {
var cb= document.getElementById('adminform');
if (checked == false) {
checked = true
}
else {
checked = false
}
for (var i =0; i < cb.elements.length; i++) {
cb.elements[i].checked = checked;
}
}
XHTML
<form id="adminform" action="" method="post">
<table id='MyTable' cellpadding='0'>
<tr>
<th class='tdleft'><input type='checkbox' name='all' onclick='checkAll(adminform);' /></th>
</tr>
<tr class='yellow'>
<td class='tdLeft'><input type='checkbox' name='id[]' value='' /></td>
</tr>
<tr class='white'>
<td class='tdLeft'><input type='checkbox' name='id[]' value='' /></td>
</tr>
<tr class='yellow'>
<td class='tdLeft'><input type='checkbox' name='id[]' value='' /></td>
</tr>
</table>
</form>