Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

247
Vistas
I want to hide a popup based on the client id and using html5 local storage

I'm quite new to all of these but here us my problem I have a popup that has a "don't show this again" checkbox. When a user checks this, local storage should save the client id (which is in the db) and the checked status of the checkbox. Based on these two factor the popup should be displayed or hidden

Here is my code:

$(document).ready(function () {

    $('#beforelight').css('display', 'block');

    $PopUp = $('#beforelight');

    var hide = JSON.parse(localStorage.getItem('hide'));
    var id = JSON.parse(localStorage.getItem('[[clientdb.id]]'));

    if (hide, id) {
        $PopUp.hide();
    } else {
        // initialize value in case it hasn't been set already
        localStorage.setItem('hide', false);
    }

    $('#checkbox').click(function () {
        $('#beforelight').hide();
        // toggle the boolean by negating its value
        var id = JSON.parse(localStorage.getItem('[[clientdb.id]]'));
        var hide = JSON.parse(localStorage.getItem('hide'));
        localStorage.setItem('hide', !hide);
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Please try this code - JSON.parse is returns string

$(document).ready(function () {

    $('#beforelight').css('display', 'block');

    $PopUp = $('#beforelight');

    var hide = JSON.parse(localStorage.getItem('hide')) === 'true';
    var id = JSON.parse(localStorage.getItem('[[clientdb.id]]'));

    if (hide && id) {
        $PopUp.hide();
    } else {
        // initialize value in case it hasn't been set already
        localStorage.setItem('hide', 'false');
    }

    $('#checkbox').click(function () {
        $('#beforelight').hide();
        // toggle the boolean by negating its value
        var id = JSON.parse(localStorage.getItem('[[clientdb.id]]'));
        var hide = JSON.parse(localStorage.getItem('hide')) === 'true';
        localStorage.setItem('hide', !hide ? 'true' : 'false');
    });
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda