Try this....
<SCRIPT LANGUAGE="JavaScript">
<!--
function ClearLevelListForm()
{
for (var i=0;i<document.LevelListForm.elements['rgItems[]'].length;i++)
{
if (document.LevelListForm.elements['rgItems[]'][i].checked == true)
{
alert(document.LevelListForm.elements['rgItems[]'][i].value);
document.LevelListForm.elements['rgItems[]'][i].checked = false;
}
}
}
//-->
</script>
PHP List wrote:
Hi,
I am hopeing someone can help me with this.
This is more of a javascript problem I suppose.
I have a bunch of check boxes on a from that I have given a name of rgItems[] so I can access them as an array in php.
But I can't find a way to clear all the checkboxes on the form at once. a reset button only resets the form to the original values, but I need to be able to clear all the check boxes.
<SCRIPT LANGUAGE="JavaScript">
<!--
function ClearLevelListForm()
{
for (var i=0;i<document.LevelListForm.elements.length;i++)
{
if (document.LevelListForm.elements[i].checked == true)
{
alert(document.LevelListForm.elements[i].value);
document.LevelListForm.elements[i].checked = false;
}
}
}
//-->
</script>
I do get the correct alerts from the above script corresponding to the number of checked boxes, however, the second line does not seem to be unchecking the boxes. I am not sure if this has something to do with the fact that all the boxes have the same name rgItems[] and the browser doesn't know which one to uncheck.
Has anybody else come accross this?
Thanks,
And I apologize for asking this question on the PHP List, but I am hoping someone here may have had the same problem when name mutliple form elements using the array style: blah[]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php