Form Question
| From: | PHP List | Date: | Thu, 31 Oct 2002 19:05:59 +0000 |
| Subject: | Form Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122311@lists.php.net to get a copy of this message | ||
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[]