I have a JSON object in session :
{ "Zone" : "Bangalore" , "Role" : "1" , "Vehicles" : [ "v123" , "v345" , "v567"]}
I need to get the values of Vehicles in ArrayList and pass to a selectBox with multiple option
Am trying something like this:
var temp = sessionStorage.getItem('userDetails');
var viewName = $.parseJSON(temp);
alert(viewName.Vehicles);
var v1 = new Array(viewName.Vehicles);
for (var i=0; i < v1.length;++i){
alert("");
addOption(document.myform1.v1, v1[i], v1[i]);
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
I am getting the values of
alert(viewName.Vehicles);
as v123,v234,v345. But I need to convert var veh as ArrayList to pass to the selectbox
The code to convert it to ArrayList is not working.