Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
113
rated 0 times [  120] [ 7]  / answers: 1 / hits: 109804  / 13 Years ago, wed, august 3, 2011, 12:00:00

Edit: It appears I was a bit confused on what I was trying to accomplish. For those that took the time to explain this, thank you.



I'm trying to create a two dimensional array in Jquery/Javascript. I've done a decent amount of searching, testing and more searching but i'm unable to find a solution that really makes sense to me. (it's been a very long week already....)



Below is the desired format of the array.



{product:[{attribute:value,attribute:value}]}

More From » jquery

 Answers
14

That's not a 2D array, but rather an object. Also, your product array contains only one object. I think you need something like this:



var obj = {};
obj.product = [];
for(var i=0; i < someObj.length; i++) {
obj.product.push[{attribute: someObj[i]}]
}


This will produce an array inside the product property:



{product:[{attribute:value}, {attribute:value}]}

[#90835] Tuesday, August 2, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stefanicarolinat

Total Points: 145
Total Questions: 91
Total Answers: 93

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
stefanicarolinat questions
Mon, Nov 15, 21, 00:00, 3 Years ago
Fri, Apr 16, 21, 00:00, 3 Years ago
Thu, Oct 15, 20, 00:00, 4 Years ago
Fri, Jul 17, 20, 00:00, 4 Years ago
;