I attempted to transfer checkbox values to another HTML page using local storage, however they were not appearing on the other page
Here is my page1 HTML code snippet:
<input class="checkbox" type="checkbox" id="option1" name="car1" value="BMW">
<label for="vehicle1">BMW</label><br>
<input class="checkbox" type="checkbox" id="option2" name="car2" value="Ferrari">
<label for="vehicle2">Ferrari</label><br>
<input checkbox="checkbox" type="checkbox" id="option3" name="car3" value="Ford">
<label for="vehicle3">Ford</label><br>
<input class="checkbox" type="checkbox" id="option4" name="car4" value="Audi">
<label for="vehicle4">Audi</label><br>
<input class="checkbox" type="checkbox" id="option5" name="car5" value="Cadillac">
<label for="vehicle5">Cadillac</label><br>
This is the Javascript code I used:
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox" && inputs[i].checked) {
count2++;
localStorage.setItem("checkvalue", inputs[i].value);
}
}
<script>
// This is the page2 script
<span id="result"></span>,Welcome
document.getElementById("result").innerHTML = localStorage.getItem("checkvalue");
</script>