value attribute | value property
Sets or retrieves the value which is returned to the server when the form control is submitted.
![]() |
Syntax
| HTML | <element value="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: String
the value of a control object which is passed as a name/value pair to the server, when an object is submitted.
Standards information
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
- HTML 4.01 Specification, Section 17.6.1
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.
Examples
This example sets the value for each option element to a supply stock number.
<script type="text/javascript"> 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>
See also
Show:
