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

162
Visualizações
Save in localstorage and db and show it later

I use Elementor Pro. I have a button that is limited to 7 clicks, when clicking number 7 is disabled, and this is saved in localstorage to display later. My problem if the user login from different device, the count start againg in 0. and obviously the code don't work for my need, The user after 7 click Never can click again.

How can resolve this?

this is the code:

<script>
 // On page load (or in whatever event creates the button)
window.addEventListener("load", ()=>{
 // Read the saved state from local storage (if not yet saved, will be null)
 let clickcount3 = localStorage.getItem("localStorage.clickcount3");

 if(localStorage.clickcount3>6)
     document.getElementById("showResultMasPack").style.visibility = "visible";

});
 
function CounterMastPack() {
if (typeof(Storage) !== "undefined") {
 if (localStorage.clickcount3) {
   localStorage.clickcount3 = Number(localStorage.clickcount3)+1;
 } else {
   localStorage.clickcount3 = 1;
 }
 document.getElementById("resultMastPack").innerHTML = localStorage.clickcount3 + " Click(s).";
} else {
 document.getElementById("resultMastPack").innerHTML = "Sorry, your browser does not support web storage...";
}
if(localStorage.clickcount3>6)
document.getElementById("showResultMasPack").style.visibility = "visible";      
}
</script> 
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