• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to JavaScript Array  RSS feed

 
Suresh Kumar Ramasamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Suresh Kumar Ramasamy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, late realisation that I have posted into wrong forum.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JSP Forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!