text Property

MS Office DHTML, HTML & CSS

text Property


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

Syntax

HTMLN/A
Scriptingobject.text [ = sTxt ]

Possible Values

sTxtString that specifies the text.

The property is read/write with no default value.

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

Remarks

The text and value properties are distinct from one another. Changing the text property does not alter an existing value, which is set within the option.

Example

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

Sample Code

<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()">
This feature requires Microsoft® Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
HTML N/A
Scripting OPTION

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.