View Single Post
Old 02-18-2007, 09:15 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,721
redhead is on a distinguished road
1) Either surround the different tables with their seperate <form></form>, and change the javascript to something like:
Code:
function checkAll(table){
	for (var i=0;i<document.forms[table].elements.length;i++)
	{
		var e=document.forms[table].elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox'))
		{
			e.checked=document.forms[table].allbox.checked;
		}
	}
}
And in your allCheck box, call it with something accordingly like
Code:
...
<input type="checkbox" value="on" name="allbox" onclick="checkAll(0);"/>
...
<input type="checkbox" value="on" name="allbox" onclick="checkAll(1);"/>
...
Or name the checkboxes something which makes sence, like:
Code:
...
<input type=checkbox name=table1_1>
<input type=checkbox name=table1_2>
...
<input type=checkbox name=table2_1>
<input type=checkbox name=table2_2>
...
And modify the javascript code to something like:
Code:
function checkAll(table){
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e=document.forms[0].elements[i];
		if ((e.name.substring(0,table.length) == table) && (e.name != 'allbox') && (e.type=='checkbox'))
		{
			e.checked=document.forms[0].allbox.checked;
		}
	}
}
And then according to the table number, call it like:
Code:
<input type="checkbox" value="on" name="allbox" onclick="checkAll("table1");"/>
2) and 3) requires some server side scripting like PHP/MySQL solutions....
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote