Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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: 67592
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]
 
Sheriff
Posts: 26793
82
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.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic