Fields pre-populated through Javascript are not submitted

I’ve added some code to onReady() for one of my pages to pre-populate some fields with values from a dataset that a user may have already submitted. The prepolulation works fine. However, when the form is submitted, the values of the prepolulated fields are not submitted. Can anyone help? Is this bug in Wix or expected behavior?

Example pre-population code:

$w.onReady(function () {
$w(“#name”).value = value;
});

Show us how your and how you are using the dataset. We’ll need more information to be able to help.

You need to use the dataset setFieldValue() function as well, to set the value in the dataset.

Awesome, thanks Sam - setting the value on the dataset resolved the problem!

I did the same thing with my sign-up forms, it auto fills the email with the currentUser email. My issue is that when the next member enters that page, they will see the previous members email. Only refreshing this page will it show the current users email.

Here’s my code for this:

let user = wixUsers.currentUser;
let email = user.getEmail()
.then((email) => {
$w(‘#input1’).value = email;
})

I am also setting the field value before save to capture and write this email to the db, and that is working fine. It’s just that the last email used isn’t clearing for the next user…