JavaScript Kit > JavaScript Reference > Here
Button Object
Last updated: June 20th, 2004
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
Related Tutorials
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.dynamicdrive.com'" value="Dynamic Drive" />
</form>
Reference List
- JavaScript Operators
- JavaScript Statements
- Global functions
- JavaScript Events
- Escape Sequences
- Reserved Words
Right column
