Reputation: 348
I have an array which I have another to push into in a loop
array1[ [box1, type1, 10], [box1, type2, 12] ]
array2[ [box2, type1, 10], [box2, type2, 12], [box2, type2, 12] ]
var curArray = new Array();
so in a loop:
var testarray = new Array('box1', 'type1', 10);
curArray.push(testarray);
and I have to post it so I set it in a hidden field. array.push works when I console.log(curArray) but if you set it to a hidden field by
$('hdnField').val(curArray)
it no longer become a multidimensional array.
Is there another way to do this?
Upvotes: 0
Views: 996
Reputation: 1259
You can try JSON.stringify()
$('hdnField').val(JSON.stringify(curArray));
Does this work?
Upvotes: 1