Forums Register Login

New to Javascript - How to work with a given array in a javascript function

+Pie Number of slices to send: Send
Hi Everybody:

I'm trying to draw a map using google visualization. For setting different places in the map, I need to pass an array to the javascript method, but I can't get it working

This is the code I'm trying to use


If I put it that way, I get the next error:

Error: missing ] after element list

Line: 122, Column: 34
Source Code:
var list=[Ljava.lang.String;@129efd0;

Does anybody know how can I store in a local array variable in javascript the value of the array in j? I've spent a lot of time googling it but I haven't got anything

Thank you very much in advance
+Pie Number of slices to send: Send
Remember that Javascript runs in the web browser, while the variable you're trying to look at exists in the Java code generated from the JSP, which runs on the server; by the time the Javascript runs, the Java variable no longer exists. What you need to do instead is write Java code to explicitly generate a Javascript array out of the Java array data. The Java code will run on the server when the page is executed, and it should create the proper Javascript code to initialize a Javascript array containing the same elements. That Javascript code will be embedded in the page, and it will be downloaded to the browser and executed there.
+Pie Number of slices to send: Send
Please read this article to understand how JSPs operate.
+Pie Number of slices to send: Send
Thank you very much for your help. Now I know a little more about JSP

Just in case another one has the same problem, here is the solution

It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 927 times.
Similar Threads
javascript error using validator
Reading <h:message values in javascript
passing javascript array from jsp to servlet
copying from one select list to another
Functionality working in IE but not Firefox (Google Map API experience helpful!)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:07:35.