Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Checkbox type

Syntax document.form.checkbox.type The type property provides access to type attribute of the check box. This property is a read-only string that always contains checkbox. <html>     <form name="orderForm">       <input type="checkbox"              name="peppers">Peppers<br>       <input type="checkbox"              name="sausage">Sausage<br>       <input type="checkbox"              name="onion">Onion<br>       <input type="checkbox"              name="bacon">Bacon<hr>       <input type="button"              value="Order Pizza"              name="orderButton"              onClick="alert('ordered.')">     </form>     <script language="JavaScript">     <!--     var counter = 0;     for(var x=0; x<document.orderForm.length; x++)     {       if(document.orderForm.elements[x].type == "checkbox")       {         counter++;       }     }     document.write("Please select no more than 2 of the ");     document.write(counter," possible toppings.");     -->     </script>     </html>