This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes HTML page refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML page refresh" Watch "HTML page refresh" New topic

HTML page refresh

subramaniam g

Joined: Dec 05, 2000
Posts: 1
I have a Html form in which certain feilds are entered by the user.for eg the form contains feilds emp id , description,
and a combo box language . when the user enters the employee id
and selects the language in the combo box, the description in the corresponding language for the employee is to reteived from the database(which is present).can i do this without refreshing the page.
if it can be please give the solution.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
If you want to change the values of one combo box based on the value of another combo box, then you will have to have the data present. By this I mean, you can't have a page talk to the database after the page is loaded, you will have to go to the database, get all the information, and then load the page. HTML is static, so once it reaches the client end, you can't talk to the database without going to the server.
However, there are ways around this. If the data you have is small enough, then you can use javascript to load all the data into an array or mulit-dimensional array using some type of server-side processing like Servlets, JSP, or ASP. Then you have sent all the data over that is necessary, so when the change the combo box, you do have the data to change the other combo box.
All depends on how much data you have, if it is small then the above is a nice solution. If you have a lot of data, then I would either go back to the database by reloading the page, or I would just give them all items and use javascript or server-side form validation to check the page after they submit the data. Sometimes there is just so much hand-holding you can do for the user.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
subramaniam g,
Your name doesn't comply with our naming standards here at JavaRanch. Could you please re-register with a more appropriate name. Check out this page for more info,
subramaniam gomatinayagam

Joined: Dec 06, 2000
Posts: 6
Thanks Bill for the speedy reply.I have re registered as instructed by you.Actually the data to be stored is quite large
and i wouldn't like to store it in the client.pls inform
if there's any other work around
else it's ok.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
If you don't want to send it over then your best option is to either:
1. Keep both drop-downs with all choices and then you javascript and/or server side validation like Servlets, ASP, Coldfusion, CGI, etc... to check the values and either accept or reject them.
2. Or you do your form in steps where the first step is to select this from this list, and then they hit submit, take them to the next page and give them the next list which you can then limit based on what they selected on the last form. You would then probably use hidden fields to keep track of what they selected on the last form so you can submit it all at once when they are finished.
It is sorta covered in the JavaRanch Style Guide.
subject: HTML page refresh
Similar Threads
Servlet getting values from a combo box
Combobox Script Required
can any one write this JSP program pls
Struts help
populate the combo box when the jsp page is first loaded