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
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

Link to comment
Share on other sites

  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.