Jump to content

select all / unselect all please help


shamsuljewel

Recommended Posts

I am use this code

while(($row=mysql_fetch_array($q1)) && $c < $limit)	
	{
		echo "<tr><td width='1%' colspan='20'><input type='checkbox' name='contact_select[]' value='$row[id]'>
		$c++;
	}

set of contact list from database

I want to check all or uncheck all by button click

I am using

<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.action.contact_select)">
  <input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.action.contact_select)">

this does not work but if I just remove the []

<input type='checkbox' name='contact_select' value='$row[id]'>

it works but I need [] for delete the particular item...so how do I select all ..any idea?

Link to comment
https://forums.phpfreaks.com/topic/74987-select-all-unselect-all-please-help/
Share on other sites

//check one, check all 
function selectAll() {
var box = document.getElementsByName('contact_select[]');
if(box) 
{
	var boxes = box.length;
		for(var i = 0; i < boxes; i++)
		{	
			if(box[i].checked)
			{
				box[i].checked = false;
			}
			else
			{
				box[i].checked = true;
			}					
		}
}
}

 

onclick="selectAll() ;"

 

should work

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.