470,855 Members | 1,111 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Passing Javascript array to Java

Hi,

I am trying to pass a bunch of checked checkboxes (Javascript array)
from page1 to the Java action class on subsequent web page (page2).
(on page 1 I have a bunch of DB rows with a checkbox,
need to iterate through pages page2 - e.g. allow user to update the fields
there)

On page1 I have a bunch of checkboxes with the same name v1
but different values (= DB rowId).

So I created a Javascript function:
function getCheckedValues(checkbox),
which returns an array of strings (value's of checked checkboxes).
On page1 I assign it to the hidden field.

<input type="hidden" name="v2"/>
in "onclick" event of page1 I execute JavaScript"

if (this.v1) v2.value=getCheckedValues(v1);
window.location.href="page2?v2=" + v2.value;

On page2 I also have:
<input type="hidden" name="v2"/>
In the Java class attached to page2 I try to do:
String [] ids = request.getParameterValues("v2");
It seems to create an array with 1 member which is blank.

I am getting the same result if I try to pass a
window.location.href="page2?v2=" + getCheckedValues(v1)
but at least I can see some comma separated id's in the IE URL.

Why is it not working ?
Is there a better solution ?

Please help !
Thank you in advance,
Oleg.

P.S.: I tried to google around and found this page:
http://www.irt.org/script/1433.htm
But I don't understand the second part of the code (looks like an incomplete
hack to me)
and need to receive that array from Java, not a Javascript.
Dec 1 '05 #1
1 8340

"Oleg Konovalov" <ok******@verizon.net> wrote in message
news:Q7rjf.348$GA2.70@trndny02...
Hi,

I am trying to pass a bunch of checked checkboxes (Javascript array)
from page1 to the Java action class on subsequent web page (page2).
(on page 1 I have a bunch of DB rows with a checkbox,
need to iterate through pages page2 - e.g. allow user to update the fields
there)


When you say "Java on a web page", do you mean JSP or Applets?

- Oliver
Dec 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Raju V.K | last post: by
10 posts views Thread by John Ortt | last post: by
7 posts views Thread by Oleg Konovalov | last post: by
104 posts views Thread by Leszek | last post: by
1 post views Thread by Eric Capps | last post: by
41 posts views Thread by Rene Nyffenegger | last post: by
2 posts views Thread by Garg | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.