var btn = document.getElementById('insert'),
s = 0; //To increment the key(+1) each time the button is clicked and the user inputs the values so the first object's key is 1 then the second one is 2 and so on
btn.addEventListener('click', function() {
var ModelMake = prompt("Enter The Model Make"),
ModelYear = prompt("Enter The Model Year"),
Km = prompt("Enter The Amount Of Km"),
Price = prompt("Enter The Price"),
Status = prompt("Enter The Car's Status"),
table = document.getElementById('table');
var tableout = document.getElementById('tableout'),
FinalPrice,
Details;
localStorage.setItem(s += 1, JSON.stringify({
ModelMake: ModelMake,
ModelYear: ModelYear,
Km: Km,
Price: Price,
Status: Status,
FinalPrice: FinalPrice,
Details: Details
}));
This code inserts the following variables values(user inputs them) in a row and each value is in a column (cell), when i refresh the object IS stored in the localStorage even when i close my browser obviously but i want a way to keep it in the html whether i refresh or close the browser without having to extract it from the localStorage because i don't know how and it's not really what i want.