472,792 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,792 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 8440

"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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.