A simple example of JS getting select value and text value, selectvalue
This article mainly introduces a simple example of JS getting select value and text value. If you need a friend, you can refer to it and hope to help you.
The Code is as follows: <select id = "cityList"> <select id = "selectId"> <option value = "0"> 0th </option> </select> <script> var selectObj = document. getElementById ('selectid'); // Add option selectId through the object. add (new Option ("first", "1") selectId. add (new Option ("second", "2") // add option selectId by id. add (new Option ("third", "3") selectId. add (new Option ("fourth", "4") // selectId by using the id (or by adding an object. onchange = function () {// obtain value and text alert (selectObj. value); alert (selectObj. options [selectObj. selectedIndex]. text); // obtain the value and text alert (selectId. value); alert (selectId. options [selectId. selectedIndex]. text); // You can also obtain the value and text alert (this. value); alert (this. options [this. selectedIndex]. text) ;}; </script> from http://www.3lian.com/edu/2014/02-27/131363.html