469,295 Members | 1,953 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,295 developers. It's quick & easy.

Passing values from javascript to JSP

I am working on a project in which i need to receive values from the user and display it dynamically below the form. After the user confirms to save it i need to save all those values in database..

I am using Javascript to display the values as they enter.But i dont know how to send those array of values to the JSP page so that i can store them in the database.

I'm stuck.. Kindly help me out.. :(

This is similar to a shopping cart where the user data needs to be displayed dynamically in the same page as and when the user selects. I've been asked to use JavaScript for the cart and after receiving final confirmation from the user the data needs to be stored in the database using JSP..

Kindly help me out.. Am really really stuck.. :(
Dec 31 '10 #1
4 3538
RamananKalirajan
607 512MB
Either you have to use Ajax or Form submission to pass the values. Use some hidden input fields and assign the values in the text box.

Thanks and Regards
Ramanan Kalirajan
Jan 3 '11 #2
Thanks Ramanan..
I really like your advice..
But i've constraint that i should complete this project using JSP and javascript alone..
So if u can give me a better solution i would be much glad..

Thanks and regards,
RAKHI
Jan 3 '11 #3
RamananKalirajan
607 512MB
I guess setting a hidden variable with the JS in a Form doesn't uses any language.

Ex:

HTML:

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="usrName" id="usrName" />
JS:

Expand|Select|Wrap|Line Numbers
  1. var frmElement = document.getElementById('usrName');
  2. frmElement.value=yourArray;
JSP:

Expand|Select|Wrap|Line Numbers
  1. String str = request.getParameter('usrName').toString();
Thanks and Regards
Ramanan Kalirajan
Jan 3 '11 #4
Hi Rakesh,

Did this suggestion help you?
Oct 13 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Jim Heavey | last post: by
1 post views Thread by olduncleamos | last post: by
2 posts views Thread by Ganesh | last post: by
1 post views Thread by Steve | last post: by
3 posts views Thread by Archanak | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.