I'm working on a JS project that creates 3 cars with 2 buttons underneath each car. One button shows the car information, the other is supposed to clear the information. I cannot seem to get the clear button to work. I've tried all kinds of things and I have a feeling it's something simple. Please help, here's my code:
<div id= "container">
<div class="row">
<div class="column">
<img src="images/Porsche.jpg">
<button onclick="display1()" id="submit1">See Details</button>
<button onclick="clear()" value="reset" id="clear">Clear Selection</button>
</div>
<div class="column">
<img src="images/Ferrari.jpg">
<button onclick="display2()" id="submit2">See Details</button>
<button onclick="clear2()" id="clear">Clear Selection</button>
</div>
<div class="column">
<img src="images/Lambo.jpg">
<button onclick="display3()" id="submit3">See Details</button>
<button onclick="clear3()" id="clear">Clear Selection</button>
</div>
</div>
</div>
var porsche = {
make: "Porsche",
model: "Panarama",
year: 2020,
available: true,
description: "The Porsche Panamera is an excellent super luxury car."
}
function display1() {
var place = document.getElementById("submit1");
for (value in porsche) {
place.innerHTML = "Make: " + porsche.make + "<br>" +
"Model: " + porsche.model + "<br>" +
"Year: " + porsche.year + "<br>" +
"Available: " + porsche.available + "<br>" +
"About: " + porsche.description;
}
};
var ferrari = {
make: "Ferrari",
model: "Panarama",
year: 2020,
available: true,
description: "Ranks near the top of super luxury cars, with a strong engine, well-balanced handling, and comfortable interior."
}
function display2() {
var place = document.getElementById("submit2");
for (value in ferrari) {
place.innerHTML = "Make: " + ferrari.make + "<br>" +
"Model: " + ferrari.model + "<br>" +
"Year: " + ferrari.year + "<br>" +
"Available: " + ferrari.available + "<br>" +
"About: " + ferrari.description;
}
};
var lambo = {
make: "Lamborghini",
model: "Huracan",
year: 2021,
available: true,
description: "Exceptionally comfortable ride and stunning performance."
}
function display3() {
var place = document.getElementById("submit3");
for (value in lambo) {
place.innerHTML = "Make: " + lambo.make + "<br>" +
"Model: " + lambo.model + "<br>" +
"Year: " + lambo.year + "<br>" +
"Available: " + lambo.available + "<br>" +
"About: " + lambo.description;
}
};
function clear() {
document.getElementById(".row").reset();
}