I have a hidden text field, whose initial value I have set to "init" for the purposes of this demonstration. The text field is bound to a field "metadata" in my database.
Now I create a visible checkbox. The code behind the checkbox is:
```
if ($w('#mycheckbox').checked) $w('#metadata').value = 'checked'; else $w('#metadata').value = 'not checked';
```
I then run the "Preview". I click the checkbox, then submit the form. Result in database: metadata = "init".
I have used the developer tools in the browser to verify that my code is being run. I even made the text field visible so I can see the value change as I click the checkbox. But the value saved to the database is always "init".
What am I doing wrong?
https://community.wix.com/velo/forum/coding-with-velo/solved-prepopulated-fields-are-not-saving-to-database
Trying to do the same with a text input, and it doesn't work!
if ($w('#radioGroup1').value === "Gratuit") { $w("#input4").value = "GRATUIT"; $w("#input4").hide(); }
import wixData from 'wix-data'; // ... if ($w('#mycheckbox').checked){ //we insert some text in the collection saying that the box was checked let toInsert = { "metaData": "Checked", }; wixData.insert("myCollection", toInsert) }else{ //we insert some text in the collection saying that the box was NOT checked
let toInsert = { "metaData": "Not Checked", }; wixData.insert("myCollection", toInsert) }