• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieving a value from html select element in jsp

 
Gopi Chand Maddula
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I am a Newbie in JSP
I have a select html element in my jsp page.
After selecting a particular value i need to capture that particular value in jsp and do my functionality with the obtained value.

How can i achieve this in jsp?
Should we use javasript for obtaining this?

Someone please help me regarding this.
producing some example code would be appreciated....!

Thanks in Advance..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about before or after the form is submitted?

If after, just use request.getParameter() in the submitted servlet to obtain the value. If before, then this is a JavaScript, not a JSP question.
 
Gopi Chand Maddula
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My functionality is to select a type of currency in a select element
and then calculate the charged amount based on the selected currency and display next to the select element automatically.

is it possible in JSP?

or should i use any other technology?

this should be done before submitting the form only...!
 
Gokul Nanthakumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to do some logic (in you case calculate) only two possible options are there

1. you should use only java script to do the calculation
2. or you should make ajax call to jsp/servlet to do the same.

I think in your problem, pure javascript based solution is enough
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is obviously not going to help. If you need help understanding how JSP works in order to understand why, I suggest this article.
 
Gaurav Ag Agarwal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ya dude can do it in java.. i think java has all the answers to your query..

Here what i suggest you can call a java script method on select=your_method();

Then in that you can calculate the currency and display it in the other text box. As


I think this solves your problem then.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav Ag Agarwal wrote:
Ya dude can do it in java.. i think java has all the answers to your query..

Here what i suggest you can call a java script method on select=your_method();

Java is not the same as JavaScript. So no, your solution does not use Java.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!