I'm actually trying to make something like a pokedex for forza horizon 5, you checked the box when you unlock everything on the car. But i have a problem when i need to use the local storage who are there. I can see them "true" in the inspector but i try a lot of thing but nothing work.
If someone has a solution for me
Thanks
My php doc to create the 500 div of cars
<?php
include('data.php');
$data = getCars();
$pagetitle = 'Equipe est OK';
include('javascript.js');
?>
<html>
<?php include('head.php'); ?>
<body>
<!-- <?php foreach($data as $value){ ?>
<li><?php echo $value["1"] . ' (' . $value["text"] . ')'; ?></li>
<?php } ?> -->
<section class="content">
<div class="content__dispo">
<?php foreach($data as $value){ ?>
<div class="block_car">
<span><?php echo $value["text"] ?></span>
<input class="input" type="checkbox">
</div>
<?php } ?> -->
</div>
</section>
</body>
</html>
and my javascript to select them and to put on them an addeventlistener for my localstorage :
var input = document.getElementsByClassName('input');
let con = 0;
for (let i = 0; i < input.length; i++) {
input[i].addEventListener("click", (e) => {
if(input[i] == true){
localStorage.setItem("input"+[i], input[i].unchecked);
} else {
localStorage.setItem("input"+[i], input[i].checked);
}
});
}
console.log(input);