Checkbox.onClick : CheckBox : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » CheckBox »

 

Checkbox.onClick









Syntax








onClick="command"



The onClick event handler is defined in an tag and specifies what to do when a check box is clicked.












<html>
    <form name="orderForm">
      <input type="checkbox"
             name="peppers"
             onClick="recommendSausage()">Peppers<br>
      <input type="checkbox"
             name="sausage">Sausage<hr>
      Step 2:
      <input type="button"
             value="Order Pizza"
             name="orderButton"
             onClick="alert('ordered.')">
    </form>
    <script language="JavaScript">
    <!--
    function recommendSausage()
    {
      if(document.orderForm.peppers.checked == true)
      {
        alert("Sausage goes well with peppers.");
      }
    }
    document.write("The pepper checkbox onClick event handler: ");

    document.write(document.orderForm.peppers.onclick);
    -->
    </script>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» CheckBox