• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Catching the content of drop down box

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a jsp question, moving there.

Eric
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic