Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with value change of select tag on jsp page

 
Arpit Maheshwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1759
19
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1759
19
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jk... life is too short to write raw JavaScript without jQuery. Especially if Ajax is going to come into the picture!
 
Arpit Maheshwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So I have to make an AJAX call for it....
Thank you everyone for the help....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic