how to get the database value without submitting the jsp page

Hi,

I have a form that has many fields (textbox/listbox). when user enter/change a value in the first textbox, I need to pass this value to the database to check whether it exist and get the other values to be displayed to other fields in that form (i cannot get the javascript value to be pass to jsp without reload/refresh/submit. But, I need to get the user entered value, so I thought of hidden popup, iframe, etc but not sure how I could apply and which best suit this case). If I submit the page then I can easily get the value thru 'request.getParameter("fieldname") but cannot use this because I cannot submit the page.

Pls help and possible provide me with the sample coding

Thanks

[717 byte] By [Mahantesha] at [2007-10-3 0:34:35]
# 1

actually my pblm is, i vill enter value into first textbox, and i vill move cursor into 2nd textfield, as soon as cursor goes into 2nd textfield, it has to check in database whether the entered value in 1st textfield is there r not, if it is there then corresponding next value in the database has to be retraive and display it in 2nd textfield, and i vill put one button(button name=NEXT) next to 2nd textfield, as i press this button i have to get same 2 textfield and one button in the next row, like this i have to get 10 values , after getting 10 rows, i have to store all these values into another table, plz help me how to do this pblm, if possible help me through coding also,

Mahantesha at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> i cannot get the javascript value to be pass to jsp without

reload/refresh/submit.

EXACTLY, how is your browser supposed to get information from the remote database without requesting it?

You have 2 options:

1) Submit a new request with each selection from a drop down

2) Write all of the data that could be required into javaScript

Option 2 is ok if you have a tiny amound of data, otherwise you will have to re-submit.

Google for javaScripts there are lots around, or, find a site that has it working, 'view source' in the browser and grab it !!

angrycata at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
i think you can do this way....just use an AJAX method to dodatabase check and alll.and call the javascript Ajax function from onChange of that textfield....
Sudharsana at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

like

<script>

function callDatabase(){

WebRemoteClient webremoteClient=new WebRemoteClient();

var inputMap=new Map();

inputMap.put("textfield1",textfield1);

webremoteClient.invoke(

--

}

</script>

just call the funtion when the value changes

<html:text property="text1" onchange='callDataBase' />

Sudharsana at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Hi,

I have a form that has many fields (textbox/listbox). when user enter/change a value in the first textbox, I need to pass this value to the database to check whether it exist and get the other values to be displayed to other fields in that form (i cannot get the javascript value to be pass to jsp without reload/refresh/submit. But, I need to get the user entered value, so I thought of hidden popup, iframe, etc but not sure how I could apply and which best suit this case). If I submit the page then I can easily get the value thru 'request.getParameter("fieldname") but cannot use this because I cannot submit the page.

Pls help and possible provide me with the sample coding

Thanks

dil07a at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
AJAX is the only solution of your problem.
rizwanrizia at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

The best way for you is surely AJAX. But there is another way to stay compatible with older browsers:

Since the default method a browser supposed to get data is refresh, there is nothing unnatural in it. Browsers are optimized to refreshes, like cached images, etc..

So for these step-by-step things, you need to roll forward your data from page to page, and make the page to respond according the data it actually have. This can be easily achived with type="hidden" input fields in a form: the user will send you back all the data. Optionally you may show him the data you already have as visible text too.

A more generalised way to "pull" the data: you make a whole page you include every time you need an additional data. This page will receive 2 parameters from where you've included it. This 2 parameters are each indexed arrays with the datas you have to pull in (here the default value), and you need to push forward. Optionally there is a 3rd parameter, the url it have to return (as the form's action property).

And for them who now say that it would me more culture way to store this data in the session: Beware! Common mistake: Sessions are to store data about the user itself, not the datas for the next page! You never know what will be the next page! The user click some backward button and refresh button, and depending on your script, it may go stupid! Ok, not all the codes, but I've seen some. It's ok to store a sent file (fx. image) on the server, but always think the evil refresh and back buttons!

MoZo1a at 2007-7-14 17:28:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...