Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching the content of drop down box

 
Prasad Darsi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I declared the drop-down menu as shown below:

<form name="myForm" action="form2.jsp">
<select name="Fruits">
<option value="" selected>Select A Fruit</option>
<option value="1">Orange</option>
<option value="2">Apple</option>
<option value="3">Banana</option>
</select>
<input type="submit" value="Submit">
</form>

After submitting the form, I am catching the value of "Fruits", and it is showing either 1,2, or 3.

I want to catch both the value and its content in "form2.jsp" so that I can post that data in the database. When the form is submitted, The value of "Fruits" is showing one of 1,2 or 3.

Is there anyway by which I can catch both the content of the drop-down box ?

Thanks in advance,
Prasad.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a jsp question, moving there.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The display text of the drop-down box is not submitted.

Presumably, you already have this info on the server so that you could generate the select element in the first place. Use the submitted value to look up the corresponding text.
 
Prasad Darsi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can fetch this value from the server by using one more query. But to do this, I have to access the database again.

Can we avoid this database access, so that I can get these two values quickly ? (I can also save some lines of code)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic