Hi,
I'm trying to transfer a date from a datepicker to another datepicker on a new page, I can get the to transfer to a text user input but not the date picker, can someone point me in the right direction please? The code I have been using is below
Page 1
import {formatDate} from "public/dates.js";
export function SearchButton_click(event, $w) {
let word = $w("#iTitle").value;
local.setItem("iTitle", word);
let wordtwo = $w('#coursenamedropdown').value;
local.setItem("coursedropdown", wordtwo)
let wordthree = $w('#dropdownDifficulty').value;
local.setItem("dropdowndifficulty", wordthree)
let wordfour = ($w('#durationdropdown').value);
local.setItem("duration", wordfour)
let wordfive = formatDate ($w('#Coursestartdate').value);
local.setItem("coursedate", wordfive)
console.log($w('#iTitle').value);
console.log($w('#coursenamedropdown').value);
console.log($w('#dropdownDifficulty').value);
console.log($w('#durationdropdown').value);
console.log($w('#Coursestartdate').value);
wixLocation.to("/results");
}
Page 2
$w.onReady(() => {
var ititleword = local.getItem("iTitle")
$w('#iTitle').value = ititleword
var courseWord = local.getItem("coursedropdown")
$w('#coursenamedropdown').value = courseWord
var diffWord = local.getItem("dropdowndifficulty")
$w('#dropdownDifficulty').value = diffWord
var durationword = local.getItem("duration")
$w('#durationdropdown').value = durationword
var dateword = local.getItem("coursedate")
$w('#Coursestartdate').value = dateword;
filter($w('#iTitle').value, $w("#coursenamedropdown").value, $w("#durationdropdown").value, $w("#Coursestartdate").value,
$w("#dropdownDifficulty").value);
local.clear();
});
I think local storage save only string type data So convert the string data type into Date In page 2
var dateword = new Date(local.getItem("coursedate")); $w('#Coursestartdate').value = dateword;
Happy to help !!
Brilliant! Thank you! @Salman
The full code for anyone else if it helps :)
Page 1
let wordfive = $w('#Coursestartdate').value; local.setItem("coursedate", wordfive)
Page 2
var dateword = new Date(local.getItem("coursedate")); $w('#Coursestartdate').value = dateword;