these strings are displayed on the faces of the buttons.
value is a read-only property.
do not confuse the value property with the name property. the name property is not displayed onscreen; it is used to reference the objects programatically.
options array
the value property is a string that initially reflects the value attribute. the value of this property can change when a program modifies it. the value property is not displayed onscreen, but is returned to the server if the option is selected.
you can set the value property at any time.
do not confuse the value property with the selection state of the select object or the text that is displayed as an option. the selected and selectedindex properties determine which options are selected, and the defaultselected property determines the default selection state. the text that is displayed in each option is specified by its text property.
checkbox and radio objects
when a value attribute is specified in htm, the value property is a string that reflects it. when a value attribute is not specified in htm, the value property is a string that evaluates to "on". the value property is not displayed onscreen, but is returned to the server if the radio button or checkbox is selected.
you can set the value property at any time.
do not confuse the value property with the selection state of the object or the text that is displayed next to each checkbox and radio button. the checked property determines the selection state of the object, and the defaultchecked property determines the default selection state. the text that is displayed is specified following the <input type="checkbox"> or the <input type="radio"> tag.
例子
the following function evaluates the value property of a group of buttons and displays it in the msgwindow window:
function valuegetter() {
var msgwindow=window.open("")
msgwindow.document.write("submitbutton.value is " +
document.valuetest.submitbutton.value + "<br>")
msgwindow.document.write("resetbutton.value is " +
document.valuetest.resetbutton.value + "<br>")
msgwindow.document.write("helpbutton.value is " +
document.valuetest.helpbutton.value + "<br>")
msgwindow.document.close()
}
this example displays the following values:
query submit reset help
the previous example assumes the buttons have been defined as follows
<input type="submit" name="submitbutton"> <input type="reset" name="resetbutton"> <input type="button" name="helpbutton" value="help">
the following function evaluates the value property of a group of radio buttons and displays it in the msgwindow window:
function valuegetter() {
var msgwindow=window.open("")
for (var i = 0; i < document.valuetest.radioobj.length; i++) {
msgwindow.document.write
("the value of radioobj[" + i + "] is " +
document.valuetest.radioobj[i].value +"<br>")
}
msgwindow.document.close()
}
this example displays the following values:
on on on on
the previous example assumes the buttons have been defined as follows
<br><input type="radio" name="radioobj">r&b <br><input type="radio" name="radioobj" checked>soul <br><input type="radio" name="radioobj">rock and roll <br><input type="radio" name="radioobj">blues
相关
for hidden, password, text, and textarea:
for button, reset, and submit:
for options array: