File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Help with value change of select tag on jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Help with value change of select tag on jsp page" Watch "Help with value change of select tag on jsp page" New topic
Author

Help with value change of select tag on jsp page

Arpit Maheshwari
Greenhorn

Joined: Dec 06, 2011
Posts: 5
What I want to do:
I have a jsp page where initially there is a single html select tag with its options retrieved from database that contains the list of moderators assigned.
On value change of the the select box i want to show the detailed description of the moderator on the same page.

Problem:
The problem is I cant get the way to retrieve data on value change as I cant take the value change from javascript and pass this value as parameter in java to retrieve the description.

So how to detect the value change in jsp...
Or suggest me some other way to deal with this problem...
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 942
    
  13

I don't see any other solution except an AJAX call. Use the JQuery onchange() event to get the option value and use that as a parameter to the AJAX call to get the description. Then insert the description into the DOM using JQuery.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

Well, the solution of AJAX suggested by Robbins is absolutely fine. I just wanted add a few points, onchange() is not an JQuery event, its an HTML event and the problem OP is having, can be solved without using JQuery also, but yes, JQuery would make it much easier, but it should be left at the discretion of OP to whether use JQuery or any other framework.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 942
    
  13

Yes, you are correct about leaving that choice to the posters discretion. My experience is with JQuery, so I'm biased that way.

JQuery, ExtJS, MooTools... whatever your favorite Javascript framework happens to be, they all make life easier than raw Javascript.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

I agree with Jk... life is too short to write raw JavaScript without jQuery. Especially if Ajax is going to come into the picture!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Arpit Maheshwari
Greenhorn

Joined: Dec 06, 2011
Posts: 5

So I have to make an AJAX call for it....
Thank you everyone for the help....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

You don't have to... you can go old-school and simply refresh the entire page, using JSP to add the new elements. But that would be so 2001...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with value change of select tag on jsp page