• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieve related data based on id selected from dropdown list

 
sheetal kaman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
Dave Tolls
Ranch Hand
Posts: 1914
14
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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]
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic