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
  • 118,400
  • 24
  • 176
  • 257
AKIWEB
  • 17,808
  • 64
  • 175
  • 282
  • 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