Forum Moderators: open

Message Too Old, No Replies

Placing variables in an array then displaying it.

         

PokeTech

9:41 pm on Apr 19, 2009 (gmt 0)

10+ Year Member



Well I'm fairly new to javascript, actually this is my second day so I'm not a pro at it. I have a question though. I have an array and I want to retrieve it by placing two variables next to each other. Like this:

var myEvents=new Array();
myEvents[413247]="Test Event";

var display = move.style.left.substring(0,3) + move.style.top.substring(0,3);
document.getElementById("event").innerHTML = myEvents[ + display + ];

Everything works except for this part:

document.getElementById("event").innerHTML = myEvents[ + display + ];

Any help is appreciated.

Fotiman

2:00 am on Apr 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Remove the + operators from that line:

document.getElementById("event").innerHTML = myEvents[display];