473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 8477

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) {...
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
3
by: John Ortt | last post by:
I appologise for reposting this but I have been trying to find a solution all week with no avail and I was hoping a repost might help somebody more knowledgable than myself to spot the message... ...
7
by: Oleg Konovalov | last post by:
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,...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
1
by: Eric Capps | last post by:
This may be more of a Java question, but I feel that JavaScript experts may be more qualified to help me find a solution. In short: is it possible to call a Java method from JavaScript, passing...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
2
by: Garg | last post by:
Hi All, I am facing one problem if you are having any solution please tell me. I have to pass an array from javascript to servlet. for this i created one array and pass that through submitting...
1
by: mariaz | last post by:
Hello, I have an array in my javascript file: var locations=new Array(); and I want to pass the attributes of the array into my java file, does anyone know how can this be done? Thank you in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.