I'm new to JavaScript and I'm still learning. So I have an object with cars:
var cars = [
{
image:'http://superbvehicles.com/wp-content/uploads/2015/10/Nissan-GTR-3.jpg',
name:'nissan',
model:'gtr',
hp:565,
price:100.000,
},
{
image:'http://bestcarmag.com/sites/default/files/4700070mitsubishi-lancer-06.jpg',
name:'mitsubishi',
model:'lancer',
hp:380,
price:40.000,
},
{
image:'http://bestcarmag.com/sites/default/files/2048005subaru-impreza-wrx-sti-01.jpg',
name:'subaru',
model:'impreza',
hp:400,
price:50.000
},
{
image:'http://stancewords.stanceworks.netdna-cdn.com/wp-content/uploads/2012/06/datsun-240z-slammed-red.jpg',
name:'nissan',
model:'fairlady 240z',
hp:200,
price:70.000
},
{
image:'https://s-media-cache-ak0.pinimg.com/736x/35/be/6b/35be6b46846e893d332ddfef989614fe.jpg',
name:'nissan',
model:'skyline',
hp:320,
price:80.000
}
]
and a html table which is filled with the information from this object. I created "edit" button for every row in the table and when you press it it takes the information for the row and inserts it into a form so the user could edit it. This is the function that does that:
function editCar(i){
var image = cars[i].image;
var name = cars[i].name;
var model = cars[i].model;
var hp = cars[i].hp;
var price = cars[i].price;
$('#image-edit').val(image);
$('#name-edit').val(name);
$('#model-edit').val(model);
$('#hp-edit').val(hp);
$('#price-edit').val(price);
var newImage = $('#image-edit').val();
var newName = $('#name-edit').val();
var newModel = $('#model-edit').val();
var newHp = $('#hp-edit').val();
var newPrice = $('#price-edit').val();
};
So my question is how can I insert the new information (provided by the user in the form) into the object in the place of the old one?
P.S. Sorry if my english is bad.
index(i)..