Transfer Datepicker value to new page

Hi!

Page 1:

import {session} from 'wix-storage'; // activates wix-storage
import wixlocation from 'wix-location';

$w.onReady(function () {
    //DROPDOWN FILTER
    $w('#searchbutton').onClick(() => {
        session.setItem("citychoice", $w("#citypick").value); 
        let startdate = String($w('#datePicker1').value);
        console.log(startdate); // log the date picker value to the console
        session.setItem("datechoice", startdate);
        wixlocation.to("/rooms");
    });
});

Page 2:

import wixData from 'wix-data';
import { session } from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function () {
    $w('#citypick2').value = session.getItem("citychoice");
    var startdate = new Date(session.getItem("datechoice")); // create a JavaScript Date object
    console.log(startdate); // log the date value to the console
    $w('#datePicker1').value = startdate;
    wixData.query("Rooms")
    .lt("availability", startdate) // use the startdate variable in the filter query
    .and(wixData.query("Rooms").contains("city", String($w('#citypick2').value)))
    .find()
    .then(results => {
        $w('#RoomRepeater').data = results.items;
        session.clear();
    });
});

If you get Errors, write it that i can better understand what the problem is :slight_smile: