Hi everyone, essentially I’m just trying to copy the input in a date selector form element into a plain text form field. So once a user enters a date, I want that value to copy to a text field. I’ve tried to get the value of the date field and then set the value of the text field, but it’s not working.
let myValue = $w("#datePicker1").value;
$w("#input5").value = myValue;
I’m only doing this because when sending an automated email there’s no way to format the date value when using a dynamic form element, so it shows up in the email as YYYY - MM - DD, so I just need to get a properly formatted date element to use in my email automation.
Thanks!
Try this one…
You can use either a Text-Box, or an Input-Field, or a normal Text-Field…
import wixData from 'wix-data';
$w.onReady(()=>{
$w("#datePicker1").onChange(()=>{
let myValue = $w("#datePicker1").value;
console.log(myValue)
$w("#input5").value = myValue.toString()
$w("#textBox5").value = myValue.toString()
$w("#text1").text = myValue.toString()
})
})

Or a better way …
import wixData from 'wix-data';
$w.onReady(()=>{
$w("#datePicker1").onChange(()=>{
let myValue = ($w("#datePicker1").value).toDateString()
console.log(myValue)
$w("#input5").value = myValue
$w("#textBox5").value = myValue
$w("#text1").text = myValue
})
})

No problem.
One little fix… —> you don’t need —> import wixData from ‘wix-data’ ;
That was just a COPY-PASTE-FAILURE!
$w.onReady(()=>{
$w("#datePicker1").onChange(()=>{
let myValue = ($w("#datePicker1").value).toDateString()
console.log(myValue)
$w("#input5").value = myValue
$w("#textBox5").value = myValue
$w("#text1").text = myValue
})
})
You can like it, if you liked it 