Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  17] [ 7]  / answers: 1 / hits: 27149  / 13 Years ago, fri, january 13, 2012, 12:00:00

Say I have an array such as this in Javascript:



var cars = { vendor: [ { type: [ 'camry', 'etc' ] } ] } 


In Javascript what command can I use to add an item to type... For example if I wanted to have a text box that a user can place text into and then hit a button that will add the item into the array. The item that would be added would need to be placed in with the same items as camry and etc. Thanks!


More From » arrays

 Answers
28

Try something like



cars.vendor[0].type.push(foo);


Where foo is your data to add.


[#88037] Thursday, January 12, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackie

Total Points: 442
Total Questions: 107
Total Answers: 94

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
jackie questions
Sat, Sep 18, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
;