1 out of 2 rated this helpful - Rate this topic

text property

[This documentation is preliminary and is subject to change.]

Sets or retrieves the text string specified by the option tag.

Syntax

JavaScript

p = object.text

Property values

Type: String

the text.

Standards information

Remarks

Assigning a value to the text property changes the text property internally, but does not cause the listed value to change. Submitting the form submits the internally stored value, not the one displayed.

Examples

This example uses the text property to change the text string of each option each time the user selects an option.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/text_3.htm


<SCRIPT>
function fnShow(){
    for(var i=0;i<oSel.options.length;i++){
		oSel.options[i].text+=" (slugs)";
}
}
function fnFlash(){
    var sQuery="";
    for(var i=0;i<oSel.options.length;i++){
        sQuery+=i + " - Value=" + oSel.options[i].value + 
        " - Text=" + oSel.options[i].text + "\n";
    }
    alert(sQuery);
}
</SCRIPT>
<SELECT ID=oSel onchange="fnFlash()">
   <OPTION VALUE="US">Seattle
   <OPTION VALUE="FRANCE">Paris
   <OPTION VALUE="MEXICO">Cabo San Lucas
</SELECT>
<INPUT TYPE=button VALUE="Show Attractions" onclick="fnShow()">

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ