Forums Register Login

JSP to JavaScript Array

+Pie Number of slices to send: Send
Hello,

While the page loads, I want to transfer some data from Server to a JavaScript array. I have accomplished it in the following (round about) way.

(1) I have defined an "on load" in the BODY tag.
(2) This function is defined as:

(3) I have the following tag within a JSP loop(originally used for displaying a different value, now reused for the current requirement).

(4) This onfocus function is defined as

/* dEIdArray is defined within the script outside any function */

Could you please suggest a better way.

Thanks.
+Pie Number of slices to send: Send
Sorry, late realisation that I have posted into wrong forum.
+Pie Number of slices to send: Send
Moving to the JSP Forum.
+Pie Number of slices to send: Send
Could you please elaborate on your problem, because your problem description and the solution you posted seem to have nothing at all to do with each other. What does putting focus on an element have to do with JavaScript arrays?
+Pie Number of slices to send: Send
[Posting here again since it appears that this post got moved into this forum and it didn't say so in the original post in the previous (Javascript) forum]

I think a much easier way to accomplish your task would be by having the following in a <script> in the <head> of your JSP:



I think that should do the trick. Although, personally I would suggest that you use JSTL tags to create a delimited string value. Store it in a hidden field and then onLoad of your body, use the split() method to convert it into an array. That would be *much* neater.
[ March 27, 2008: Message edited by: Anirvan Majumdar ]
Slime does not pay. Always keep your tiny ad dry.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 5023 times.
Similar Threads
JSP to JavaScript Array
Why always show the javascript class AutoSuggestControl is not defined?
Calling javascript function in js file from JSP
passing javascript array from jsp to servlet
using css at run time
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:54:03.