aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

advice need - howto make this effect ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 439
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
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Nakata,
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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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
Sheriff

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 http://simple.souther.us/not-so-simple.html. 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: 439
thanks for warm input , i try the sample of Ben Souther , thanks for your hardwork
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61429
    
  67

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: advice need - howto make this effect ?