Button Object
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!
CSGNetwork Custom Search
     Bookmark and Share
 
CSGNetwork
Snippets
Calculators
Top Free Apps
Home
Back



Right click this window and select "view source" in order to copy the source for this script.

Button Object

Form buttons (<input type="button">) within your form can be accessed and manipulated using JavaScript via the corresponding Button object. To access a button in JavaScript, use the syntax:

document.myform.buttonname //where myform and buttonname are names of your form/element.
document.myform.elements[i] //where i is the position of the button within form

Events

Events Description
onClick Code is executed when user clicks on the button. Example(s).

Properties

Properties Description
accessKey String value that sets/ returns the accessKey for the button.
disabled Boolean value that sets/ returns whether the button is disabled.
form References the form that contains the reset button.
name Reflects the name of the button (the name attribute).
type A property available on all form elements, "type" returns the type of the calling form element, in this case, "button".
value A read only string that specifies the value of the button.

Methods

Methods Description
blur() Removes focus away from the button.
click() Simulates a user clicking on the form button.
focus() Sets focus on the button.

Examples

onClick

This example creates a form button that goes to a URL when clicked on.

<form>
<input type="button" onClick="window.location='http://www.csgnetwork.com'" value="Dynamic Drive" />
</form>



Bookmark and Share
Registered® Trademark™ and Copyright© 1973 - CSG, Computer Support Group, Inc. and CSGNetwork.Com All Rights Reserved