-3

HI i have a matrix aray like below

var pricemultiarray = {
    "Coast-to-Coast": {
        "1": ["10", "20", "30", "50", "60"],
            "2": ["15", "30", "40", "60", "80"],
            "3": ["20", "40", "50", "70", "100"],
            "4": ["20", "40", "50", "70", "100"],
            "5": ["20", "45", "60", "95", "115"],
            "6": ["20", "45", "60", "95", "115"],
            "7": ["25", "55", "75", "105", "125"]
    },

        "mid-states": {
        "1": ["10", "20", "30", "45", "55"],
            "2": ["15", "30", "40", "45", "70"],
            "3": ["20", "40", "50", "60", "95"],
            "4": ["20", "40", "50", "60", "95"],
            "5": ["20", "45", "60", "90", "110"],
            "6": ["20", "45", "60", "90", "110"],
            "7": ["25", "55", "75", "105", "125"]
    },


        "In-State": {
        "1": ["10", "15", "20", "45", "50"],
            "2": ["10", "20", "25", "50", "60"],
            "3": ["10", "25", "35", "70", "80"],
            "4": ["10", "25", "35", "70", "80"],
            "5": ["10", "25", "30", "85", "95"],
            "6": ["10", "25", "30", "85", "95"],
            "7": ["25", "55", "75", "105", "125"]
    }


};

in this i need to get a particular value from the array like

1 Coast-to-Coast -> 1 -> 3

so what will b the syntax of getting the above value form the array. Please suggest

2
  • 1
    It is a good question - I am really sorry for the -1, but I think you need some motivation to repair your writing quality. Commented May 15, 2014 at 6:00
  • 1 Coast-to-Coast -> 1 -> 3 what do you mean by ? Commented May 15, 2014 at 6:01

3 Answers 3

2

Try this

pricemultiarray["Coast-to-Coast"]["1"] will return ["10","20","30","50","60"] and pricemultiarray["Coast-to-Coast"]["1"][0] will return "10"

Sign up to request clarification or add additional context in comments.

Comments

0

like this

for ( var i = 1; i <= 3; i++ ) {
alert(pricemultiarray["Coast-to-Coast"][i]);
//console.log(pricemultiarray["Coast-to-Coast"][i]);
}

Demo Fiddle

Comments

0

ok thanks guts for al of your help i use the below code

var coast = (document.getElementById("coast").value); var boxsize = (document.getElementById("boxsize").value); var day = (document.getElementById("day").value); alert(pricemultiarray[coast][boxsize][day]);

and it works fine now for me

thanks a lot

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.