A button to copy paste data between input fields (e.g. from client address to delivery address)

I have a form used to create an order.

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.

Any idea?

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?

1 Like

Yes, exactly.
Thank you for your answer.
It’s finally also what came to my mind.

From what I read while searching this forum, it seems impossible to run any javascript on a page in Glide? No workaround that, right ?

1 Like

I’m not sure, but maybe you can try it by creating a temporary usc column via the user table.

What are you trying to do with javascript? You can run javascript in the table using a javascript column, but you can’t run it in the front end.

1 Like

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:

const contactAddress = document.getElementById('contactAddress').value;
const deliveryField = document.getElementById('deliveryAddress');
deliveryAddress.value = contactAddress;

But this does not seem possible and your first proposal seems to be the way to go with Glide.
I’ve implemented it, and it works.

1 Like

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.

Don’t know if this addresses your needs. I’ll show you the magic of connecting to the user table.

Screenshot 2024-06-22 at 12.29.49


1 Like

Yes, that’a a beautiful solution, thanks :pray:

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 :

  1. Copy the content of the Name fields of the Users table to the Address fields of the Orders table (as explained above).

  2. 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).

1 Like

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.

Yes, this is considered best practice when using custom forms.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.