I use the following way to set values of form fields programmatically.
$w.('#fieldName').value = 'some data'
I have several UserInput fields. They are all connected to a database collection. If I enter data manually into all of the fields, they all get stored in the database. If I use code (like stated above) to enter data to some fields - those fields will not get stored while other fields (with manually entered data) will get stored.
I used console.log() to see if values were set the same way for the manually entered fields and the programmatically entered fields - it looks the same.
I tried manually appending a character to the programmatically entered fields and then the entire data (programmatically entered and manually entered) was stored.
I am guessing that there is some kind of an attribute on each field that indicates whether it was changed or not, and setting the values using code does not trigger the attribute change to reflect the true state of the field.
I hope I am missing something - like a click on some attribute or something.
Please help
This issue has been raised on this forum a couple of months ago. I think I remember it was a bug and wix fixed something and asked the issuer to try it agian. Unfortunately, I cannot remember by whom. Have you tried searching this forum on a couple of keywords?
Alon, I will give you the same workaround as I did in the above case, assuming that you use a standard submit button attached to the dataset (in ots props you set it to Submit).
Detach the button fron the dataset (turning it into a normal button) and on the onClick, do a .save(). That should work.
I face the same problem with fields populated with jquery. The fields go blank when another field is changed either programmatically or manually. Did you find a solution to this?
@yisrael-wix It’s not a jQuery question. jQuery does it’s part fine. It’s AFTER when I enter values in other fields, it removes the value programmatically. Also, it’s not sent over to form submission value.
@deepakm Not sure what you’re doing, but jQuery is not supported in Wix Code. Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor.Please include the name of the page involved, and explain what you do to see the problem.
“If an element is connected to a dataset, setting the element’s value in code does not set the value of the connected field in the dataset. That means if you use the dataset to perform a submit, the value changed in code is not reflected in the submitted item.
To submit the new value using a dataset, set the field’s value using the setFieldValue() function before performing the submit.”
“same issue”? If the answer provided in the thread doesn’t address your problem, then you most probably are encountering a different issue.
Please add your own issue into a new post instead of bumping up an old post. Explain what you are trying to do, what works, and what doesn’t. Also, add any code in a code block as stated in the Forum Guidelines .