Checkbox : CheckBox « Form « JavaScript Tutorial

JavaScript Tutorial
1. Language Basics
2. Operators
3. Statement
4. Development
5. Number Data Type
6. String
7. Function
8. Global
9. Math
10. Form
11. Array
12. Date
13. Dialogs
14. Document
15. Event
16. Location
17. Navigator
18. Screen
19. Window
20. History
21. HTML Tags
22. Style
23. DOM Node
24. Drag Drop
25. Object Oriented
26. Regular Expressions
27. XML
28. GUI Components
29. Dojo toolkit
30. jQuery
31. Animation
32. MS JScript
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript Tutorial » Form » CheckBox 
10. 7. 1. Checkbox

The Checkbox object represents a graphical check box.

Check boxes are created as part of a form by using the tag with the TYPE attribute set to checkbox in an HTML document.

Once created, check boxes can be accessed in JavaScript as an element of a form using dot notation.

Check boxes can also be grouped together under the same name and accessed as an array by using brackets.

Arguments, Properties, Methods, and Event Handlers Associated with the Checkbox Object are listed in the following table.

checkedA Boolean value that determines if the check box is checked.
defaultCheckedA Boolean value that holds the initial state of the check box. This value is set with the CHECKED attribute.
formReturns the Form object of the check box.
nameThe string specified in the NAME attribute of the HTML tag.
typeThe string specified in the TYPE attribute of the HTML tag. This string is always checkbox for the Checkbox object.
valueThe value returned when the form is submitted.
blur()Removes focus from the check box.
click()Calls the check box's onClick event handler.
focus()Applies focus to this check box.
handleEvent()Passes an event to the appropriate event handler associated with the check box.
onBlurThe handler invoked when focus is removed from the check box.
onClickThe handler invoked when the check box is selected.
onFocusThe handler invoked when focus is applied to the check box.


<html>
    <script language="JavaScript">
    <!--
    function submitOrder()
    {
      var alertString = String("Order: ");
      if(document.orderForm.lettuceCB.checked == true)
        alertString += " with lettuce ";      
      if(document.orderForm.cheeseCB.checked == true)
        alertString += "with cheese ";        
      if(document.orderForm.tomatoeCB.checked == true)
        alertString += "with tomatoe ";       
      alert(alertString);
    }
    -->
    </script>
    <form name="orderForm">
      Lettuce
      <input type="checkbox" value="lettuce" name="lettuceCB"><br>
      Cheese 
      <input type="checkbox" value="cheese" name="cheeseCB"><br>
      Tomatoe
      <input type="checkbox" value="tomatoe"name="tomatoeCB"><hr>
      Step 2:
      <input type="button" value="Submit Order" name="orderButton" onClick="submitOrder()">
    </form>

    </html>
10. 7. CheckBox
10. 7. 1. Checkbox
10. 7. 2. Checkbox.blur()
10. 7. 3. Checkbox.checked
10. 7. 4. Checkbox.click()
10. 7. 5. Checkbox.defaultChecked
10. 7. 6. Checkbox.focus()
10. 7. 7. Checkbox.form
10. 7. 8. Checkbox.handleEvent()
10. 7. 9. Checkbox.name
10. 7. 10. Checkbox.onBlur
10. 7. 11. Checkbox.onClick
10. 7. 12. Checkbox.onFocus
10. 7. 13. Checkbox.type
10. 7. 14. Checkbox.value
10. 7. 15. Check if a CheckBox checked
10. 7. 16. With with RADIO and CheckBox
10. 7. 17. Use checkbox to control the window style
10. 7. 18. A Checkbox and an onclick Event Handler
10. 7. 19. A Checkbox, an onclick Event Handler and show/hide form controls
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.