Hello
I am trying to use javascript and PHP together to be able to select all checkboxes in an array within a certain group of checkboxes.
My code in the header is as follows:
<script>
function select(a) {
var theForm = document.myForm;
for (i=0; i<theForm.elements.length; i++) {
if (theForm.elements[i].name=='mycheckbox[]')
theForm.elements[i].checked = a;
}
}
</script>
The site lists properties, you click on a property name, it will open up (on the same page) and list all users allowed to view that property.. You can click on the name again and the list of users will disappear. I want to be able to select All checkboxes for this group without affecting any other properties on the page. I will have a list of 8 properties with approximately 30 users underneath each property.
Within a while loop I place the property name, with a hide funcation for all of the users underneath. The loop then places all of the users from a database under the name, the following code is set up for each checkbox:
<form name="myForm">
<input type='checkbox' name='mycheckbox[]' value='{$propf['us_id']}'>
</form>
<a href='javascript:select(1)'>Check All</a> | <a href='javascript:select(0)'>Uncheck All</a>
I have used an ID number for each of the group checkboxes and I still receive the following error when I click on 'Check All':
Message: 'elements.length' is null or not an object
Line: 12
Char: 12
Code: 0
Can anyone help me figure this out?


