Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
Problem on checking local.storage item on load

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);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda