I would like to add to my wix site a calendar date picker whereby a user selects a date.
Depending on the date selected, text to appear which then appears below:
“This needs to be done by DD/MM/YY [6 months before date selected]”
“This should to be done by DD/MM/YY [3 months before date selected]”
“This should to be done by DD/MM/YY [1 month before date selected]”
The date in the text being a pre-determined setting of months/days before the date selected which I would choose/set.
Ok so I have put that code in the page code, and the both the date picker and text box have ID #myDatePicker and #messageText but I get error = newDate.LocaleDateString is not a function
hi, thank you for your help. so I used the code but changed the value before toLocaleDateString();:
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
export function myDatePicker_change(event) { var d = new Date($w(“#myDatePicker”).value); var newDate = d.setMonth(d.getMonth() - 3); var d1 = new Date($w(“#myDatePicker”).value); var newDate1 = d1.setMonth(d1.getMonth() - 4); var d2 = new Date($w(“#myDatePicker”).value); var newDate2 = d2.setMonth(d2.getMonth() - 5);
$w("#messageText").text = "Sending invitations should be done by " + d.toLocaleDateString();
$w("#messageText2").text = "Sending flowers should be done by " + d1.toLocaleDateString()
$w("#messageText3").text = "Sending RSVP should be done by " + d2.toLocaleDateString();
}
This seems to work fine.
Few questions:
what happens if I want to subtract an amount of days rather than months?
at the moment each text box has “text” “text2” in it which displays until a user selects date and it changes. how can I make it so the text boxes are blank and update/show only once a date is picked ?