• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp + dropdown + automatically populate the vales from the db in the Text box

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My dropdown has 3 values. Based on the selection of a particular value, the next 2 text box values should automatically (values are taken from the databse) displayed in the corresponding text boxes. How can i do that??
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Onchange of the first dropdown list, submit the form, fetch the values from the database and generate the other two drop-downs with the values fetched from the database. You could pass ArrayLists from session attributes.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've put together a demo app that does this with a mock database object.
http://simple.souther.us/not-so-simple.html
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Javascript, when choose the first drop-down, reload the page and then display the second one.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben Souther, i seen your sample DynamicSelectLists.war before posting this question. But i am not able to understand.
If you give small piece of sample code, that's better..
Without reloading/ submiting the page...is it possible ???
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If you dont want reloading the page, then you have to go for JavaScript and fetch all the data necessary to populate the textbox before the JSP is loaded.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kri shan:
Hi Ben Souther, i seen your sample DynamicSelectLists.war before posting this question. But i am not able to understand.
If you give small piece of sample code, that's better..
Without reloading/ submiting the page...is it possible ???



It is possible to do this without reloading the page.
As JsBhaskar said, you would do this with Javascript code, not server side Java. Also, you would have to load all the possible information into the page when it is first drawn. For small amounts of data, this is fine.

There is a forum for HTML/Javascript on this site:
https://coderanch.com/forums/f-20/HTML-JavaScript
 
Sheriff
Posts: 67746
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
Another, somewhat advanced, possibility is to use the XmlHttpRequest Javascript object to send a "behind the scenes" request to the server without having to refresh the page. This is an elegant solution, but requires a good grasp of the principles involved.
 
reply
    Bookmark Topic Watch Topic
  • New Topic