Option.text : Option Object : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Option Object »

 

Option.text







The text property specifies the text for the selected option of the select list.












<html>
    <head>
    <title> Example of the text property of the option object</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    function check(myForm){
       for (var i = 0; i < document.form1.myList.length; i++) {
          if (document.form1.myList.options[i].selected == true) {
             alert("The selected text value is: " + document.form1.myList.options[i].text);
          }
       }
    }
    -->
    </script>
    <form name=form1>
    <select name="myList" multiple>
    <option value=1>One
    <option value=2>Two
    <option value=3>Three
    <option value=4>Four
    </select><P>
    <input type="button" value="Get Text Value" onClick='check(this.form)'>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Option Object