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?