0

I have created a webapp using servlet and jsp where I have a dropdown tag in html as below

<select id='check' name='select1'>
<option value='1'>text1</option>
<option value='2'>text2</option>
</select>

how can I access a TEXT not VALUE from select box using javascript?

so I can display text1 or text2 instead of 1 & 2, in my webapp.

I tried doing this, but it always gives me the "value" text not the option text?

 <%
       String checkText= request.getParameter("select1");
 %>
<script>
      document.getElementById("check").value = '<% out.print(checkText); %>';
</script>
Pshemo
  • 122,468
  • 25
  • 185
  • 269
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
  • 2
    how about http://stackoverflow.com/questions/1085801/how-to-get-the-selected-value-of-dropdownlist-using-javascript – ug_ Jan 03 '14 at 22:28

1 Answers1

1

Can be done using jquery check this How do I grab and send a dropdown's display text instead of value using jquery

Community
  • 1
  • 1