• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and JavaScript  RSS feed

 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay so here is my delema, I have a JSP variable that is base don user input. Basically need to have a drop down change based on what the user selects. So a god for instance would be the user selects a class they want to take and a drop down below it changes dynamically based on a Java class to the current available classes. So, both fields are dynamic and are pulled from a SQL database, which i have figured out, but in pseudocode it would look like so:

MAKE drop down class menu
INPUT Geometry
MAKE drop down openings
INPUT openings
SUBMIT

then a table builds showing who is in that class (done it already)

any questions lemme know.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search this forum, you will see that that this has been asked many times. You either have to post the page back to the server for each drop down and table, or use Ajax to do this.

Eric
 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wanna avoid AJAX
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you will need to post back to the server.

I have an example app that does this:
http://simple.souther.us/not-so-simple.html

If the amount of data is small and somewhat fixed, you could build javascript arrays on the and do all of this on the client.
 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know how to make dynamic lists, but want the second lists contents to be beased on the first ones.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to post your form back to the server when the option is changed in the first dropdown list and fill in the second list.

onchange="document.formName.submit()"

then you can see the values and adjust them. Not that hard to do.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also been covered in these forums on many occasions. Use the Search, Luke!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Patrick Mallahan:
i know how to make dynamic lists, but want the second lists contents to be beased on the first ones.


Which is precisely what the example I gave you does.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:

I have an example app that does this:
http://simple.souther.us/not-so-simple.html


Ben, that's a fantastic web site. Those might be the best-documented, clearest examples of this kind of system that I've ever seen. I'm reading this thread because I need to do something like this (actually a bit worse, with dynamically-added form elements) and this is a big help.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!