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, enabled click, focus onClick, onFocus check box form, name, value, checked, defaultChecked, enabled click, focus onClick, onFocus radio form, name, value, checked, enabled click, focus onClick, onFocus combo form, name, value, enabled, listCount, list, multiSelect, listIndex click, focus, removeItem, addItem, clear onClick, onFocus password form, name, value, defaultValue, enabled focus, blur, select onFocus, onBlur text, text area form, name, value, defaultValue, enabled 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, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Gets the form object containing the element.
element.form
Part Description element Returns an object expression that evaluates to an intrinsic control.
An object expression that evaluates to the form containing the element
All elements
name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, 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, enabled, listCount, multiSelect, listIndex, 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, enabled, listCount, multiSelect, listIndex, 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, text area
form, name, value, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Gets or sets the checked state of the check box or the radio button.
element.checked [=bool]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. Sets the checked state of the check box or the radio button.
Returns TRUE if the check box or radio button is checked; FALSE if not.
check box, radio button
form, name, value, defaultValue, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Gets or sets the default checked property of the check box.
element.defaultChecked [=bool]
Part Description element An object expression that evaluates to an intrinsic control. string Optional. Sets the default state of the check box.
Returns TRUE if the check box is checked by default; FALSE if not.
check box
form, name, value, defaultValue, checked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Gets or sets whether the control is enabled.
element.enabled [=bool]
Part Description element An object expression that evaluates to an intrinsic control. bool Optional. Enables or disables the control.
Returns TRUE if the control is enabled; FALSE if not.
All elements
form, name, value, defaultValue, checked, defaultChecked, listCount, multiSelect, listIndex, length, options, selectedIndex
Gets the count of elements in the list.
element.listCount
Part Description element An object expression that evaluates to an intrinsic control.
Returns the number of elements in the combo box.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, multiSelect, listIndex, length, options, selectedIndex
Gets or sets whether the combo is multiselect or not.
element.multiSelect [=bool]
Part Description element An object expression that evaluates to an intrinsic control. bool Optional. Use TRUE to set the combo to multiselect; FALSE to set to single-select.
Returns TRUE if the combo is multiselect; FALSE if not.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, listIndex, length, options, selectedIndex
Gets or sets the list index.
element.listIndex [=integer]
Part Description element An object expression that evaluates to an intrinsic control. Integer Optional. The list index to select. Note that this must be between 0 and ListCount - 1.
Returns the index of the currently selected element. If more than one is selected, it returns the first.
listIndex is the index of the selected element in the combo. Applies to the combo element.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, 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, enabled, listCount, multiSelect, listIndex, 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 string specifying the <options> tag 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, enabled, listCount, multiSelect, listIndex, length, selectedIndex
Gets the index for the selected option (or the first option selected when there are multiple selected objects).
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, enabled, listCount, multiSelect, listIndex, length, options
Clicks the element.
element.click
Part Description element An object expression that evaluates to an intrinsic control.
button, reset, submit, check box, radio, combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Sets the focus to the element.
element.focus
Part Description element An object expression that evaluates to an intrinsic control.
All elements
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, 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, text area
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, 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, text area
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Removes the item at index from the element.
element.removeItem index
Part Description element An object expression that evaluates to an intrinsic control. index The index of the item to remove. Note that this must be between 0 and ListCount - 1.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Adds the item to the element before the item at index.
element.addItem index
Part Description element An object expression that evaluates to an intrinsic control. index The index of the item to add. Note that this must be between 0 and ListCount.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Clears the contents of the element.
element.clear index
Part Description element An object expression that evaluates to an intrinsic control. index The index of the item to clear.
combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, 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 me"> <script for="Button1" event="onClick" language="VBScript"> alert "I've been pressed" document.Form1.Button1.value="OUCH" </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, check box, radio, combo
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Fired when the element gets the focus.
element.onFocus
Value Description element An object expression that evaluates to an intrinsic control.
All elements
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Fired when the element loses the focus.
element.onBlur
Value Description element An object expression that evaluates to an intrinsic control.
password, text, text area
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex
Fired when the element has changed.
element.onChange
Value Description element An object expression that evaluates to an intrinsic control.
text, text area
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, 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, text area
form, name, value, defaultValue, checked, defaultChecked, enabled, listCount, multiSelect, listIndex, length, options, selectedIndex