Button
A bit of disambiguation: in this document, I am referring to the button form element (<input type="button">) rather than the HTML button object (<BUTTON>content</BUTTON>). I haven't had much use for the latter, but if/when I decide to study it, I'll document it elsewhere.
Basics
Bare-bones code for a button is:
<INPUT TYPE="button" VALUE="Label">
This renders the button only with the VALUE appearing as text on the button. It's possible to omit the VALUE, but the button may not display at all if this is done.
Usage
The button element renders a button that does nothing, in and of itself, but can be used to trigger client-side scripting.
Processing
A button does not pass any data to the server for processing.
HTML Attributes
A button typically has only name and value, though the following attributes may also be specified:
- ACCESSKEY - A shortcut key to put focus on the element.
- DISABLED - Grays out the element and prevents the user from altering its value.
- TABINDEX - Specified as a number, this alters the default tabbing order of a form.
Worth noting: the text supplied as the VALUE will be displayed on the button, and may be text only (not HTML code to format it)
JavaScript
Properties
A button has no unique or unusual JavaScript properties.
Methods
- click() - Simulates a user click on the button.
Event Handlers
- onclick - Takes effect when the element is clicked
Misc Notes
If a script to be executed before form submission has the potential to abort the submission of the form, a generic button can be substituted for a submit button such that, if conditions are acceptable, can trigger the form's submit() method after executing all other commands.