Exforsys.com
 
Home Tutorials JavaScript
 

JavaScript Browser Objects Part 2

 

JavaScript Checkbox Object

Page 2 of 2


checkbox object:

Checkbox is a field that allows multiple selections for the user from a group. The checkbox object of JavaScript is used to access a checkbox that is present in a form. The checkbox object is a property of the form object.



 
General syntax of checkbox object in JavaScript is as follows:


<
INPUT TYPE="checkbox" NAME="some name" VALUE="some value" CHECKED onClick="Functionname">



For example:



<
INPUT TYPE="checkbox" NAME="Exforsys" VALUE="2" CHECKED onClick="Testfunc">



In the above example, the attributes CHECKED and onClick are optional and the TYPE, NAME and VALUE are mandatory. The above statement creates a checkbox that belongs to a group. If it is selected or checked, the value given in the parameter (in this example 2) is returned followed by invocation of the function Testfunc.
 
The following are the properties associated with checkbox object:


  • checked
  • form
  • name
  • type
  • value

checked:

checked property of checkbox object indicates that the value is true when the button is checked.


defaultChecked:

defaultChecked property of checkbox object has the value true if the checkbox object by default is in checked state.


form:

form property of checkbox object indicates the form object, including the checkbox button.


name:

name property of checkbox object denotes the name of the checkbox button


type:

type property of checkbox object denotes the type of element as checkbox.


value:

value property of checkbox object denotes the value of the button.


Methods of checkbox object:

  • blur()
  • click()
  • focus()

blur():

The blur() method of JavaScript belongs to the checkbox object and takes the focus away from the checkbox.


click():

The click() method of JavaScript belongs to the checkbox object and is used to indicate the checkbox as clicked as if the user has clicked it.


focus():

The click() method of JavaScript belongs to the checkbox object and is used to give the focus to the checkbox.




First Page: JavaScript Browser Objects Part 2


Read Next: JavaScript Introduction

 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape