1<select id="ddlViewBy">
2 <option value="1">test1</option>
3 <option value="2" selected="selected">test2</option>
4 <option value="3">test3</option>
5</select>
6
7<script>
8 var e = document.getElementById("ddlViewBy");
9 var strUser = e.value; // 2
10 var strUser = e.options[e.selectedIndex].text; //test2
11</script>
1 <body>
2
3 <select id="list" style="padding: 10px;" onchange="getSelectValue();">
4 <option value="js">JavaScript</option>
5 <option value="php">PHP</option>
6 <option value="c#">Csharp</option>
7 <option value="java">Java</option>
8 <option value="node">Node.js</option>
9 </select>
10
11 <script>
12 function getSelectValue()
13 {
14 var selectedValue = document.getElementById("list").value;
15 alert(selectedValue);
16 }
17 getSelectValue();
18 </script>
19 </body>