Hello dear friends,
today we encountered a minor problem with JS, we need to select ray of data from JSON, here is a fragment of that JSON:
Code:
[

    {
        "Name": "1",
        "BodyStyles": [
            {
                "Name": "Coupe",
                "Models": [
                    {
                        "Name": "128i Coupe",
                        "Years": {
                            "2008": [
                                "0820",
                                "0821"
                            ],
                            "2009": [
                                "0920",
                                "0921"
                            ],
                            "2010": [
                                "1020",
                                "1021"
                            ],
                            "2011": [
                                "1120",
                                "1121"
                            ],
                            "2012": [
                                "121A",
                                "121B"
                            ]
                        }
                    },
                    {
                        "Name": "135i Coupe",
                        "Years": {
                            "2008": [
                                "0822"
                            ],
                            "2009": [
                                "0922"
                            ],
                            "2010": [
                                "1022"
                            ],
                            "2011": [
                                "1122"
                            ],
                            "2012": [
                                "121C"
                            ]
                        }
                    },
And here is the JS that we use to get the data from the Years:
javascript Code:
var years = data[series_index].BodyStyles[style_index].Models[model_index].Years;
for(i=0; i<years.length; i++){
    model_content=model_content+'<option value="'+years[i]+'">'+years[0]+'</option>';
}

This does not work, returns an error.
So what are we doing wrong? Please help...