Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  104] [ 4]  / answers: 1 / hits: 20121  / 13 Years ago, wed, february 1, 2012, 12:00:00

I have an array set out like this:



var newCircles = [{
num: 0,
name: title0,
x: 280,
y: 200,
color: #555555,
r: 60
},
{
num: 1,
name: title1,
x: 480,
y: 200,
color: #555555,
r: 80
}];


And I'm trying to push new set of information like this:



$(newCircles).push(', { num: '+newCircles.length+', name : title '+(newCircles.length)+', x : '+newCircles[chosenCircle].x+', y : '+newCircles[chosenCircle].y+', color : #7f38a7, r : '+newCircles[chosenCircle].r+' }');


But it's not working. Anyone have any suggestions?


More From » arrays

 Answers
7

you are pushing a string into the array.
if you want to push another object into the array, then do so by



newCircles.push( {
num: newCircles.length,
name: 'title ' + newCircles.length,
x: newCircles[chosenCircle].x,
y: newCircles[chosenCircle].y,
color : #7f38a7,
r: newCircles[chosenCircle].r
} );

[#87692] Tuesday, January 31, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jordenfabiand

Total Points: 678
Total Questions: 107
Total Answers: 95

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
;