Hello, I have the following problem:
The vacation is written into the cms (vacationDB) via a “set_vacation” page via 2 input fields (vacationStart & vacationEnd) and a “save vacation” button. This works.
But now I would like to read out the vacation period on the start page of the website: if today’s date is >= vacationStart AND <= vacationEnd → then I want to redirected to another page “Show vacation period to the webSite users” .
I have the following script for this, but unfortunately it doesn’t work…
//
<script type="text/javascript">
$w.onReady(function () {
const vacationUrl = "/coming-soon-01";
wixData.query("vacationDB")
.find()
.then(function(results) {
if (results.items.length > 0) {
const vacationPeriod = results.items[0];
const today = new Date();
if (today >= vacationPeriod.vacationStart && heute <= vacationPeriod.vacationEnd) {
wixLocation.to(vacationUrl);
}
}
})
.catch(function(error) {
console.log(error);
});
});
</script>
Can anybody help me?
thx Manfred
Hello, I have the following problem:
The vacation is written into the cms (vacationDB) via a “set_vacation” page via 2 input fields (vacationStart & vacationEnd) and a “save vacation” button. This works.
But now I would like to read out the vacation period on the start page of the website: if today’s date is >= vacationStart AND <= vacationEnd → then I want to redirected to another page “Show vacation period to the webSite users” .
I have the following script for this, but unfortunately it doesn’t work…
//
Can anybody help me?
thx Manfred