Infolinks In Text Ads

Aug 3, 2010

Check box validation in javascript

Check box validation : In java script for selectAll check box and deselect all check box. there are two functions for  selectAll check box and deselect all check box in java script.

<HTML>
 <HEAD>
  <script>
    function selectAllCheckBox(){
        var len = document.testForm.chkb.length;
        //alert(len);
        for(var i=0; i<len; i++){
            //alert(document.testForm.chkb[i].checked);
            document.testForm.chkb[i].checked=true;
        }
    }

    function deselectAllCheckBox(){
        var len = document.testForm.chkb.length;
        //alert(len);
        for(var i=0; i<len; i++){
            //alert(document.testForm.chkb[i].checked);
            document.testForm.chkb[i].checked=false;
        }
    }
  </script>
 
 </HEAD>

 <BODY>
  <form name="testForm">
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <INPUT TYPE="checkbox" NAME="chkb"><br/>
  <input type="button" name="Select All" value="Select ALL" onclick="selectAllCheckBox();"/>
  <input type="button" name="Deselect All" value="Select ALL" onclick="deselectAllCheckBox()"/>
  </form>
 </BODY>
</HTML>

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...