• 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

Retrieve related data based on id selected from dropdown list

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to retrieve data based on what I select the option from the dropdown menu.
This dropdown menu has ID values of the table, which I have already created.
Please can you assist me retrieving the related data from the database on selecting the ID?

I have dynamically retrieved the ID values from database table into dropdown menu.

On selecting value from the dropdown, I want to display the related data using java code.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which bit are you stuck on?

Have you got a method in your db layer to retrieve something based on a given ID?

How do you want to retrieve the thing whose ID has been selected? Are we talking a RESTful service call?
If so, have you managed to write the code on the client to make that call? Is there an endpoint on the server that can receive that request?
 
sheetal kaman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply.

I am new to programming.

I have a drop down ..the dropdown has the primary key ID values from table which are dynamically stored.
Say the values dropdown contains is 1, 2, 3. Till this I have done coding. I am even able to generate output for it using below code.




Now if I select the option 1, it should display the related records with respect to that id i.e the data with ID = 1.
How can I code it?
 
Sheriff
Posts: 67747
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
First, familiarize yourself with how Java web apps should be structured by reading this article.
 
sheetal kaman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_database

Can you please check the above site?

I am in need of that kind of output.

Please help me. [only with java]
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before you dive head-first into using AJAX, I think you need to catch up with basic knowledge.

So start with a basic HTML form which contains that <select> element and arrange things so that it submits to a servlet which handles the selected option appropriately. You can generate that HTML with your Java code, as you are doing now, if you like.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic