input (type="button")NN 2 IE 3 DOM 1  

  

The button object is a form control generated with an input element whose type attribute is set to "button". The button's text label comes from its value attribute and property. This element is similar to, but differs from, the button element. For details on the distinctions, see the button HTML element description in Chapter 8.

 
HTML Equivalent
 
<input type="button">
 
Object Model Reference
 
[window.]document.formName.elementName
[window.]document.forms[i].elements[i]
[window.]document.getElementById("elementID")
 
Object-Specific Properties
 
dataFlddataSrcformnametypevalue
 
Object-Specific Methods
 
createTextRange( )handleEvent[ ]
 
Object-Specific Event Handler Properties
 
HandlerNNIEDOM
onblur642
onclick232
onfocus642
onmousedown442
onmousemove642
onmouseout642
onmouseover642
onmouseup442
dataFldNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to associate a remote data source column name to a button object's value property. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac.

 
Example
 
document.myForm.myButton.dataFld = "linkURL";
 
Value

Case-sensitive identifier of the data source column.

 
Default

None.

dataSrcNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Content from the data source is specified via the datafld attribute. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac.

 
Example
 
document.myForm.myButton.dataSrc = "DBSRC3";
 
Value

Case-sensitive identifier of the data source.

 
Default

None.

formNN 2 IE 3 DOM 1  

Read-only  

Returns a reference to the form element that contains the current element. When processing an event from this element, the event handler function automatically has access to the input element (as the event object's target or srcElement property). By reading the form property, the script can easily access other controls within the same form.

 
Example
 
var theForm = evt.srcElement.form;
 
Value

form element object reference.

 
Default

None.

nameNN 2 IE 3 DOM 1  

Read/Write  

This is the identifier associated with the form control. The value of this property is submitted as one-half of the name/value pair when the form is submitted to the server. Names are hidden from user view, since control labels are assigned via other means, depending on the control type. Form control names may also be used by script references to the objects. Despite the modern standards' preference for the id attribute, many browsers still require that a form control be assigned a name attribute to allow the control's value to be submitted.

 
Example
 
document.orderForm.myButton.name = "Win32";
 
Value

Case-sensitive string identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character.

 
Default

None.

typeNN 3 IE 4 DOM 1  

Read-only  

Returns the type of form control element. The value is returned in all lowercase letters. It may be necessary to cycle through all form elements in search of specific types to do some processing on (e.g., emptying all form controls of type "text" while leaving other controls untouched).

 
Example
 
if (document.forms[0].elements[3].type == "button") {
    // process button input type here
}
 
Value

Any of the following constants (as a string): button | checkbox | file | hidden | image | password | radio | reset | select-multiple | select-one | submit | text | textarea.

 
Default

checkbox

valueNN 2 IE 3 DOM 1  

Read/Write  

This is one of the rare times that the value property controls the label of a form control: the text that appears on the button. A button input element is not submitted with the form.

 
Example
 
document.forms[0].myButton.value = "Undo";
 
Value

String.

 
Default

None.

createTextRange( )NN n/a IE 4(Win) DOM n/a  

  

Creates a TextRange object containing the button's label text. See the TextRange object for details.

 
Parameters

None.

 
Returned Value

TextRange object.

handleEvent[ ]NN |4| IE n/a DOM n/a  

handleEvent(event)

  

Instructs the object to accept and process the event whose specifications are passed as the parameter to the method. The object must have an event handler for the event type to process the event. Navigator 4 only.

 
Parameters
 
  • A Navigator 4 event object.
 
Returned Value

None.