I created an element in my form that should generate a field in a database. This should be generated today’s date.
I followed the guidelines. I copied and pasted the code below.
$ w.onReady (function () {
// Gets today’s date
const today = new Date ();
// Sets the property of the text element to be the string representing today’s date in the user’s local format
$ w (‘# input20’). text = today.toLocaleDateString ();
});
input20 is the field that will receive the date.
But the date is not appearing in the field in question.
Help-me. Please.
Edison the spaces are showing between $ and w and also . and text. The wix code Editor is probably underlining this section of code and flagging an error.
$w.onReady( function () {
// Gets today’s date const today = new Date();
// Sets the property of the text element to be a string representing today’s date in the user’s local format
$w(‘#input20’) = today.toLocaleDateString();
});
Ele deveria retornar a data de hoje no campo ‘input20’
Mas não retorna.
The input field should be set to a value. A text field should be set to text or html. Since I assume input20 is an input field then you should use value
<— Hover over any element property or function name and you have quick access to the documentation. You can also do this when the auto complete for the element is displayed.
Its always a good idea to read these documents when you are trouble shooting. You will probably solve many of your challenges this way.
This space only appears here in the forum. On the page it does not exist.
I copied and pasted this code from wix’s own help page. I just substituted the field name for “input20”.
I’m having the same problem and am using the correct code, but its still not working. any chance you could tell me how to make sure my input20 is actually an input element?