Hello. First off, this is my first time to use this platform or any other platform at least in web design.
So, here’s the problem. I have coded a checkbox so, if checked, will make a few elements show up. However, whenever the site is refreshed or reopened, the check on the checkbox disappears, along with the elements that it showed up.
My question is how can I make it so that regardless of how many times I refresh the page, the checkbox will remain checked?
Here’s the code I’m currently using, the one that allows a few elements to appear from checking the checkbox.
export function checkbox5_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
if ($w('#checkbox5').checked) {
$w('#image36').show()
$w('#text75').show()
$w('#text76').show()
$w('#text77').show()
$w('#button38').show()
$w('#vectorImage1').show()
} else {
$w('#image36').hide()
$w('#text75').hide()
$w('#text76').hide()
$w('#text77').hide()
$w('#button38').hide()
$w('#vectorImage1').hide()
}
}
This is the code I tried to use to make my desired output happen (the one that doesn’t work for me).
export function checkbox5_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
$w.onReady(function () {
$w('#checkbox5').onChange( (event, $w) => {
if ($w('#checkbox5').checked) {
$w('#image36').show()
$w('#text75').show()
$w('#text76').show()
$w('#text77').show()
$w('#button38').show()
$w('#vectorImage1').show()
} else {
$w('#image36').hide()
$w('#text75').hide()
$w('#text76').hide()
$w('#text77').hide()
$w('#button38').hide()
$w('#vectorImage1').hide()
}
}
So, am I doing something wrong with the code I’m trying to do, or is there another line of code I’m supposed to be using?