How to check all the check box???

A

Anonymous

Guest
I used the array to display the check boxes.

Code:
<? include ("./verify_session1.php"); ?>
<? setcookie("username1", $username1); ?>
<html>
<head>
	<SCRIPT language=JavaScript 
	src="check.js"></SCRIPT>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#12A9E2" text="#000000">
<div align="left">
<p><font face="Arial Narrow" size="4">Welcome, <b> 
	<?php 
		(" $HTTP_COOKIE_VARS as $username1" );
		print ( "$username1" );
	?></b> ! </font></p>	
<p align="center"> <font color = "Blue" align=left><font color="#FFFFFF" size="4" face="Arial Narrow"><b>
This is for joining societies.</b></font></font> </p></div>

<?
$Connect = mysql_connect("localhost", "root", "");
mysql_select_db("mw");
$result = mysql_query("select * from society1 order by society");
?>

<TABLE Border=0 width=200 align="left" height="63" >
  <TR> 
    <TD > 
      <center>
        <FORM action = "society_confirm1.php" method ="post">
          <p align="left">
            <?
				while ($number_of_array = mysql_fetch_array($result)) 
				{
					echo "<tr><td width='3%' style='border-style: none; border-width: medium'><input type='checkbox' name='society[]' value='$number_of_array[society]'></td><td width='18%' style='border-style: none; border-width: medium' colspan='2'><font color='#111111'>$number_of_array[society]</font></td></tr>";
				}
			?>
          </p><div align="left"><BR>
		  <INPUT TYPE = "submit" VALUE = "Submit" align = middle >
          <INPUT type = "reset" VALUE = "Clear" align = middle>
          </div>
        </FORM>
      </center>
    </TD>
  </TR>
</TABLE>
</body>
</html>
 
Using the attribute "checked":
Code:
<input name="blahblah" type="checkbox" value="blahblah" checked>
 
I'm not too familiar with javascript and I'm assuming you want something like hotmail where you click the top check and all of them get checked?

Use something like this for the check box which makes all buttons be checked

Code:
<input type="checkbox" OnMouseClick="society[].checked=true">
[/code]
 
they get all the check box through a loop
and then set their value to true
psudo
when main check button is checked
i =0
for all the check boxes on display for email i to n ..
check.checked=true
 
Code:
<script language=javascript>
function select_all()
{
len = document.elementname.length;

for (i=0;i<len;i++) {
document.elementname[i].checked = true;
}

}
</script>
<input type=button value='Select All' onClick="select_all();">
 
i think the last one, which using the javascript is work but i found that the javascript coding may be got something need to be change, is it? please tell me.
 
the elementname is the name of the element eg

Code:
<input type="checkbox" name="someid">
here the someid is the name of the element

but be sure you keep the name of the element same if you have to select all the check boxes
 
please help me change on the coding that i had post up, provide the check all button or something like hotmail select all check box.
 
here this should satisfy you fully :D :D

Code:
<html>
<head>
<script language=javascript> 
function select_all() 
{ 
var len = document.form1.someid.length;

for (i=0;i<len;i++) { 
document.form1.someid[i].checked = true; 
} 

} 
</script> 
</head>
<body>
<FORM METHOD=POST Name="form1">
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
<INPUT TYPE="checkbox" NAME="someid"><br>
</FORM>
<p>
<input type=button value='Select All' onClick="select_all();">

you can make a new function copy all the contents of select_all function and just replace checked=true for false and you will get Deselect all
:idea:
 
Back
Top