![]() |
![]() |
![]() |
![]() |
An object that resides below the document in the scripting object model. Elements are intrinsic HTML controls or objects. Controls are placed on a document with the <INPUT> tag while objects are placed on a document with the <OBJECT> tag.
![]()
Elements are intrinsic HTML controls (placed on a page through the input tag <INPUT>) or objects that are insertable in HTML via the object tag <OBJECT>. These include ActiveX Controls. They can be referenced either by array or name, but this reference must follow the form identifier. Not all properties, methods, and events apply to all elements. Some properties apply to all elements; some only apply to specific elements. See the list below for details by element type, then see the specific method, event, or property documentation for details.
Element Properties Methods Events button, reset, submit form, name, value click onClick checkbox form, name, value, checked, defaultChecked click onClick radio form, name, value, checked click, focus onClick password form, name, value, defaultValue focus, blur, select text, textarea form, name, value, defaultValue focus, blur, select onFocus, onBlur, onChange, onSelect select name, length, options, selectedIndex focus, blur onFocus, onBlur, onChange hidden name, value
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Gets the form object containing the element.
element.form
Part Description element An object expression that evaluates to the form containing the element
Returns an object expression that evaluates to a form object.
All elements except select and hidden.
name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Gets or sets the name of the element.
element.name [=string]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. A string containing the new element name.
Returns a string containing the name of the element.
All elements
form, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Gets or sets the value of the element.
element.value [=string]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. A string containing the new element value.
Returns a string containing the value of the element.
All elements
form, name, defaultValue, checked, defaultChecked, length, options, selectedIndex
Gets or sets the default value of the element.
element.defaultValue [=string]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. A string containing the new default value.
Returns a string containing the default value of the element.
password, text, textarea
form, name, value, checked, defaultChecked, length, options, selectedIndex
Gets or sets the checked state of the checkbox.
element.checked [=bool]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. Sets the checked state of the checkbox or the radio button.
Returns 1 if the checkbox or radio button is checked; 0 if not.
checkbox, radio button
form, name, value, defaultValue, defaultChecked, length, options, selectedIndex
Gets or sets the default checked property of the checkbox.
element.defaultChecked [=bool]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. Sets the default state of the checkbox.
Returns TRUE if the checkbox is checked by default; FALSE if not.
checkbox
form, name, value, defaultValue, checked, length, options, selectedIndex
Gets the number of options in a select element.
element.length
Part Description element An object expression that evaluates to a select element.
Returns an integer specifying the number of options in a select element.
select
form, name, value, defaultValue, checked, defaultChecked, options, selectedIndex
Gets the <options> tags for a select element.
element.options
Part Description element An object expression that evaluates to a select element.
Returns an object with the <options> for a select element.
The options array has the following properties:
defaultSelected Identifies the currently selected attribute. index Specifies the index of an option. length Specifies the number of options in the selected object. name Specifies the name attribute of the selected object. selected Used to programmatically select an option. selectedIndex Specifies the index of the selected option. text Specifies the text to be displayed (this text follows the <option> tag). value Specifies the value attribute.
select
form, name, value, defaultValue, checked, defaultChecked, length, selectedIndex
Gets the index for the selected option (or the first option selected when there are multiple selected options).
element.selectedIndex
Part Description element An object expression that evaluates to a select element.
Returns an integer specifying the index for the selected option in a select element.
select
form, name, value, defaultValue, checked, defaultChecked, length, options
Clicks the element.
element.click
Part Description element An object expression that evaluates to an intrinsic control.
button, reset, submit, checkbox, radio
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Sets the focus to the element.
element.focus
Part Description element An object expression that evaluates to an intrinsic control.
password, text, textarea, select
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Clears the focus from the element.
element.blur
Part Description element An object expression that evaluates to an intrinsic control.
password, text, textarea, select
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Selects the contents of the element.
element.select
Part Description element An object expression that evaluates to an intrinsic control.
password, text, textarea
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
There are two ways to script events from objects:
<form name="Form1"> <input type="button" name="Button1" value="Press me" onClick="pressed"> </form> <script language="VBScript"> sub pressed alert "I've been pressed" document.Form1.Button1.value="OUCH" end sub </script>
<form name="Form1"> input type="button" name="Button1" value="Press"> <script for="Button1" event="onClick" language="VBScript"> alert "Button pressed" document.Form1.Button1.value="Pressed" </script> </form>
Fired when the element is clicked.
element.onClick
Value Description element An object expression that evaluates to an intrinsic control.
button, reset, submit, checkbox, radio
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Fired when the element gets the focus.
element.onFocus
Value Description element An object expression that evaluates to an intrinsic control.
select, text, textarea
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Fired when the element loses the focus.
element.onBlur
Value Description element An object expression that evaluates to an intrinsic control.
select, text, textarea
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Fired when the element has changed.
element.onChange
Value Description element An object expression that evaluates to an intrinsic control.
select, text, textarea
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
Fired when the contents of the element are selected.
element.onSelect
Value Description element An object expression that evaluates to an intrinsic control.
text, textarea
form, name, value, defaultValue, checked, defaultChecked, length, options, selectedIndex
![]() |
![]() |
![]() |
![]() |