jim.shamlin.com

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:

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

Event Handlers


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.