Hi all,
I am starting to work on a select all function for personal project for myself and this is my code
<script type="text/javascript">
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
</script>
<body>
<form method="post" name="myForm" onsubmit="return false;">
<table>
<tr>
<th>Select All</th>
<th><input type="checkbox"
onclick="SetAllCheckBoxes('myForm', 'myCheckbox', true);" ondblclick="SetAllCheckBoxes('myForm', 'myCheckbox', false);">
</th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
<tr>
<th>Name</th>
<th><input type="checkbox" name="myCheckbox"></th>
</tr>
</table>
</form>
Ive seen on msn hotmail they use sort of thing where if you tick or check the select all tick box it ticks all of them if you untick the select all tick box it unticks them all ive sort of got it the way i have it but only with double click how can i do it with single click what do i need to change so when i click on it once it switches from unchecked to check and vice versa?
Can anyone help me here?
Thanks,William