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

105
Visualizações
save dynamic multiple checkboxes state on page reload
<div class="form-check-inline">
    <label class="form-check-label">
      <input type="checkbox" onclick="checkAll(this)" onchange="onChange(this)" value="all" name="check" class="form-check-input"> All
    </label>
</div>
<div class="form-check-inline">
    <label class="form-check-label">
        <input type="checkbox" onclick="checkAll(this)" onchange="onChange(this)" name="check" value="pending" class="form-check-input"> Pending
    </label>
</div>
  <div class="form-check-inline">
    <label class="form-check-label">
      <input type="checkbox" onclick="checkAll(this)" onchange="onChange(this)" name="check" value="confirmed" class="form-check-input"> Confirmed
    </label>
</div>
<div class="form-check-inline">
    <label class="form-check-label">
        <input type="checkbox" onclick="checkAll(this)" onchange="onChange(this)" name="check" value="received" class="form-check-input"> Received
    </label>
</div>
<div class="form-check-inline">
    <label class="form-check-label">
      <input type="checkbox" onclick="checkAll(this)" onchange="onChange(this)" name="check" value="returned" class="form-check-input"> Returned
    </label>
</div> 

I have these checkboxes and what im doing is i want to save the states of the checkboxes on page reload. I have these additional codes for

selecting only one checkbox

function checkAll(checkbox) {
    var checkboxes = document.getElementsByName('check');
    var checkeditem = document.querySelector('.form-check-input:checked').value;
        
    checkboxes.forEach((item) => {
        if (item !== checkbox) item.checked = false;
    })
} 

and for reloading the current page and adding parameters on the url

function onChange(element) {
  const urlParams = new URLSearchParams(window.location.search);

  urlParams.set("value", element.value);

  window.location.search = urlParams;
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can save the state in LocalStorage (answered hereenter link description here) or you can save it to a server.

about 4 years ago · Juan Pablo Isaza Relatório
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