Select All CheckBoxes

[Total: 0    Average: 0/5]

Form checkboxes can be all selected by choosing the “all” option.

Head Code:

<script>
<!-- Begin
var checkflag = "false";
function check(field)
{
 var i;
 if (eval(field[0].checked))
 {
  for (i=0;i<field.length;i++)
    field[i].checked=true;
  LL(field); 
  return "Uncheck All";
 } 
 else
 { 
   for(i=0;i<field.length;i++)
     field[i].checked=false;
   UU(field); 
   return "Check All";
 } 
}
function LL(field){field.disabled=true;}
function UU(field){field.disabled=false;}
function submitOrder(_form)
{
  var _msg  = "None Clicked:n";
      _msg += "Air, Monitoring, Water, Pollution Prevention checkboxes have ";
      _msg += "been deselected, please select 'All' checkbox.n";
  var anyClicked=false;
  for(var i=0;i<_form.list.length;i++)
    if(_form.list[i].checked)
	{
	  anyClicked=true;
	  _msg += "true*n";
    }
	else
	{
	  _msg += "false*n";
	}
  if(!anyClicked)
    alert(_msg)
//
  var _msg2  = "All Clicked:n";
      _msg2 += "Air, Monitoring, Water, Pollution Prevention checkboxes have ";
      _msg2 += "been deselected, please select 'All' checkbox.n";
  var allClicked2=true;
  for(var i=0;i<_form.list.length;i++)
    if(!_form.list[i].checked)
	{
	  allClicked2=false;
	  _msg2 += "false*n";
    }
	else
	{
	  _msg2 += "true*n";
	}
  if(allClicked2)
    alert(_msg2)
}
//  End -->
</script>

Body Code:

<FORM  method=post name=f1>
<table>
<tr><td>

<INPUT type=checkbox name=list   value="Check All"
onClick="this.value=check(this.form.list);">All<br>
<INPUT type=checkbox name=list value="2">Air<br>
<INPUT type=checkbox name=list value="3">Monitoring<br>
<INPUT type=checkbox name=list value="4">Water<br>
<INPUT type=checkbox name=list value="5">Pollution Prevention<br>

</table>
<INPUT class=lightbluecell style="FONT-FAMILY: verdana, arial, helvetica;
FONT-SIZE: 10px" type=submit value=Go  onclick=submitOrder()  value="Submit
Order">&nbsp;
<INPUT class=lightbluecell style="FONT-FAMILY: verdana, arial, helvetica;
FONT-SIZE: 10px" type=reset value=Clear>
 <INPUT name=orderButton onclick=submitOrder(this.form) type=button value="Submit
Order">
</FORM>

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *