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);
});
});
$(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');
});
});