VALUE Attribute | value

HTML (DHTML)

VALUE Attribute | value Property

Internet Development Index

Sets or retrieves the value which is returned to the server when the form control is submitted.

Syntax

HTML<ELEMENT VALUE = sValue... >
Scriptingobject.value [ = sValue ]

Possible Values

sValueString that specifies or receives the value of a control object which is passed as a name/value pair to the server, when an object is submitted.

The property is read/write. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

Remarks

Individual control objects return a value to the server only if they have been selected by the user.

You may pass server-friendly data directly to the server without confusing the user. The user sees only the innerText displayed, and not the value.

Example

This example sets the value for each option element to a supply stock number.

<SCRIPT>
<script>
function fnShowText(){
/* Use the selectedIndex property of the SELECT control
to retrieve the text from the options collection. */
var sText = "Stock Number = " + oSel.options(oSel.selectedIndex).value;
alert(sText);
}
</script>
<SELECT ID="oSel" onchange = "fnShowText()">
<OPTION VALUE="STK#45">Item One - Basketball</OPTION>
<OPTION VALUE="STK#347">Item Two - Baseball</OPTION>
<OPTION VALUE="STK#67">Item Three - Hockey Puck</OPTION>
</SELECT>
</SCRIPT>

Standards Information

This property is defined in HTML 3.2 Non-Microsoft link and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 Non-Microsoft link.

Applies To

OPTION, SELECT

See Also

input