• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Help with value change of select tag on jsp page

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67637
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So I have to make an AJAX call for it....
Thank you everyone for the help....
 
Bear Bibeault
Sheriff
Posts: 67637
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
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...
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic