Checkbox.onFocus : CheckBox : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » CheckBox »

 

Checkbox.onFocus









Syntax








onFocus="command"



The onFocus event handler is defined in an tag and specifies what to do when a check box gains focus.












<html>
    <form name="orderForm">
      <input type="checkbox"
             name="peppers">Peppers<br>
      <input type="checkbox"
             name="sausage"
             onFocus="chooseExtraCheese()">Sausage<br>
      <input type="checkbox"
             name="cheese">Extra Cheese<hr>
      <input type="button"
             value="Order Pizza"
             name="orderButton"
             onClick="alert('ordered.')">
    </form>
    <script language="JavaScript">
    <!--
    function chooseExtraCheese()
    {
      if(document.orderForm.sausage.checked == false)
      {
        document.orderForm.cheese.checked = true;
      }
    }
    document.write("checkbox onFocus event handler: ");

    document.write(document.orderForm.sausage.onFocus);

    -->
    </script>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» CheckBox