File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes advice need - howto make this effect ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

advice need - howto make this effect ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 465
hi, good day , assume i have 3 textfields in jsp,

when user key in data into first textfield , and the remaining second and third textfield automatically display out the value based on first textfield 's data , the display data in 2nd, 3rd textfield's data are query from DB and first textfield belong to primary key

thank in advance for your guidance ...thank you
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

So you need to go to the database after the first field is entered. I recommend graying out the second and third until they are filled in to avoid confusion.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ola Daniel
Ranch Hand

Joined: Jul 27, 2005
Posts: 105
Or you could have the values that are going to fill in the textfields in the scope of the page(request object most likely) in a vector and iterate through the vector based on the entry in the first textfield, I would suggest using a drop down menu instead of a textfield, that way you can streamline entries made in to the first field.

SCJP 1.4, SCWCD 1.4
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler et al, Refactoring: Improving the Design of Existing Code, 1999
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

There are several ways that you can do this.

One would be to use AJAX to make a call to the server when the first field is selected or filled out.

Another is to submit whole form after the first field is filled out, query the database, and redraw the whole page with the results. I have an example app that does this on Look for DynamicSelectLists.

All of this assumes a strong knowledge of JSP/Servlets and web programming in general.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 465
thanks for warm input , i try the sample of Ben Souther , thanks for your hardwork
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63841

Nakata, please don't spread the same question across multiple topics. Since you have recived an answer in the new topic you opened in the HTML forum, I'm going to close this one.

In the future, please confine the discussion of a single question to a single topic.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: advice need - howto make this effect ?
It's not a secret anymore!