From: Brandon Jake12jake Date: 2010-05-16T09:45:09+09:00 Subject: Accessing elements of a ruby array with javascript So I'm very new to both ruby and javascript, but the basic problem is. I have a ruby array @events_this_month, and i'm running a javascript loop that basically needs the information from this array. The problem is I can't seem to set the proper index for my ruby array. What I have looks like this: for( var i = 0; i < 3; i++) { var title = '<%= @events_this_month[i].title %>'; alert(title); } I've also tried: <%= $j = 0 %> for( var i = 0; i < 3; i++) { var title = '<%= @events_this_month[$j].title %>'; alert('<%= $j %>'); <%= $j = $j +1 %> } Any suggestions on how I can access the correct index in my ruby array during the javascript loop? -- Posted via http://www.ruby-forum.com/.