count the number of check boxes selected
<HTML><Head><title></title> <Script> functionStatic_num () {document.getElementById ("btnoperate"). onclick= function () { vararr= NewArray (); varItems=Document.getelementsbyname ("category"); for(i= 0; I<items.length; I++) { if(items[i].checked) {Arr.push (items[i].value); }} alert ("the number of choices is:" +arr.length); }; }; </Script></Head><Body> <P><inputtype= "checkbox"name= "category"value= "topic of the Day" />Today's Topic</P> <P><inputtype= "checkbox"name= "category"value= "Visual Focus" />Visual focus</P> <P><inputtype= "checkbox"name= "category"value= "Finance" />Financial</P> <P><inputtype= "checkbox"name= "category"value= "Car" />Car</P> <P><inputtype= "checkbox"name= "category"value= "Technology" />Technology</P> <P><inputtype= "checkbox"name= "category"value= "Property" />Property</P> <P><inputtype= "checkbox"name= "category"value= "Travel" />Tourism</P> <P><inputID= "Btnoperate"type= "button"value= "Select"onclick= "Static_num ()" /></P></Body></HTML>
Effect
Click the check box to perform the appropriate function
<HTML><Head><title></title> <Script> functionMini (TXT) {document.getElementById ('Show_text'). InnerHTML=txt;}</Script></Head><Body> <inputtype= "checkbox"name= "category"value= "topic of the Day"onclick= "Mini (' Hello ')"/>today's topic<DivID= "Show_text"> </Div></Body></HTML>
Effect
Status of the check box
<HTML><Head><title></title> <Script> functionMy_func () {varItems=Document.getelementsbyname ("category"); document.getElementById ("node" +String (1). InnerHTML= "Node1" + ":" +items[0].checked; document.getElementById ("Node2"). InnerHTML= "Node2" + ":" +items[1].checked;}</Script><DivID= "Node1">Node1</Div><DivID= "Node2">Node2</Div></Head><Body> <P><inputtype= "checkbox"checked name= "category"value= "topic of the Day"onclick= "My_func ()"/>Today's Topic</P> <P><inputtype= "checkbox"checked name= "category"value= "Visual Focus"onclick= "My_func ()"/>Visual focus</P></Body></HTML>
Effect
Before execution
After execution
HTML check box checkbox