Jump to content


how to make "Select All" for checkbox???

  • Please log in to reply
2 replies to this topic

#1 airwinx

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 18 July 2006 - 05:29 AM

is there any example of code of how to make "select all" check box????

#2 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 18 July 2006 - 05:54 AM

Easyest way would be javascript, not PHP.
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:

#3 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 18 July 2006 - 06:44 AM


if (isset($_GET['box'])) foreach($_GET['box'] as $v) {
	echo "Box $v is checked <br>";
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test check boxes</title>
<SCRIPT language="javascript">
         function checkall(form) {
              for (var i=0; i<form.elements.length; i++) {
              	if (form.elements[i].type == "checkbox") {
              		form.elements[i].checked = true;
	<input type="button" name="chkall" value="All"   onclick="checkall(this.form)">
	<input type="checkbox" name="box[]" value="123"> Select 123<br>
	<input type="checkbox" name="box[]" value="124"> Select 124<br>
	<input type="checkbox" name="box[]" value="125"> Select 125<br>

<INPUT TYPE="submit" value="Submit"> 

(Moving to javascript forum)
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users