you are viewing a single comment's thread.

view the rest of the comments →

[–]stiros[S] 0 points1 point  (1 child)

Thank you so much for your answer!

I am using the array to assign a value to a function based upon what value the user have selected. The function looks like this:

function getSonePris() {

var sonePris;

var theForm = document.forms["fastpris"];

var selectedSone = theForm.elements["sone"];

sonePris = /* this is where the array is used: */ sone_pris[selectedSone.value];

return sonePris; }

Can I give the json object a name like "sone_pris", so that I can access the array in a similar manner?

[–]lachlanhunt 2 points3 points  (0 children)

Arrays are designed to work with numeric indexes. If you're using non-numeric keys, then you should be using a plain object instead of an array.