The form contains input fields for the address, zip, city of the client and other fields for the address, city, zip of the delivery.
I would like to have a button that copies the data entered by the user from the client’s fields to the delivery’s fields.
I tried to use the “Set column values” action, but it’s not working because at the time when the button is clicked, the record is not yet created and there’s no data in the table.
At the time the user clicks the button, the data is only on the screen.
Rather than copy the data, couldn’t you just have a checkbox that says ‘Same as above’, and then adjust your backend to use either address depending on if the checkbox is checked or not?
I was simply trying to read the value of an input field and copy the value into another field, on a form screen (I wanted a button to trigger the copy).
In plain javascript that would be as simple as that:
I tried that too. And to run javascript through a javascript column.
But the problem was I could not to capture the value of the input field, neither set a value to the other field.
Actually, I couldn’t reach the DOM to manipulate it.
But it’s fine, I’ve implemented the solution indicated by Jeff_Hager in his first reply and it’s working.
At least, I have a solution to present to my customer.
But as in the end, it’s not in the Users table that I want to save the data entered in the form, but a new order (the form is attached to the Orders table).
The content entered by the user in the {User > Name 1} and {User >Name 2} fields on the form must be transferred to the Orders table, at some point.
So in addition to your example, I also need to add an action to the ON SUBMIT action of the form.
That action does 2 “Set column values” actions :
Copy the content of the Name fields of the Users table to the Address fields of the Orders table (as explained above).
Clear the data from the Name 1 and Name 2 fields of the Users table so that the next time I call the form, the Name 1 (i.e. Address 1) and Name 2 (i.e Address 2) fields are empty.
I’ve tested it and it works !
But all in all, it’s a lot of work, fields and actions for a small feature that would require little work on a traditional html/javascript website.
PS: Actually it’s better to clear the Name 1 and Name 2 values in the Users table when opening the Add form, not when submitting it (because, if I open the form, add values in the Name fields without submitting and close the form, the values entered will reappear the next time I open the form).
What I mentioned above is just an explanatory example. For Name1 and Name2 in the Users table, you actually only need one field as a temporary storage place which you can paste into all the fields and which you can delete at the same time as the copy action, so it doesn’t have to be done during the submit or add form action (if you want to delete it or keep it for future convenience).
Once everything is loaded into the form, the rest is just the usual action of creating a form in Glide.