This code obviously doesn't work in JavaScript, but how do I do this in JS?
It should be obvious from the code but I need to assign an array key value (so 'a', '5' and '8' in the example below) - unfortunately I do need to have a letter, so 0, 1, 2 etc. is no good.
I've seen something to do with objects and 'a':'op1' but it doesn't seem to work an I'm getting errors such as " Unexpected token : " - I bet this is easy when you know how?
var options = new Array('a' => 'op1', '5' => 'op2', '8' => 'op3');
for(x in options) {
var value = options[x];
alert("the key is " + value[0]);
alert("the value is " + value[1]);
}
jQuery or native JS, whichever is best is fine (I'm using jQuery on that page anyway)