How to copy the value in one field to other field on the same form?

rkreddy
Giga Expert

Hi Everyone,

I have fields like Name, Address, Country etc on a form, and I have the same related fields in a section of the same form. I have a Yes/No field on the form, when the user select yes, I need to copy the values in Name, Address, Country to related fields in other section of the same form. Could you please help me on this. Thanks in Advance

Regards,

Rakesh

1 ACCEPTED SOLUTION

Joshwa Antony S
Mega Guru

Hi,

 

Create onChange client script that run when the Yes selected in Yes/No field.

Keep the script like this

//check field name and change

var copiedFrom = ['name', 'address', 'country'];
var copiedTo = ['other_name', 'other_address', 'other_country'];


if (newValue == 'yes') {
    for (var i = 0; i < copiedFrom.length; i++) {
        g_form.setValue(copiedTo[i], g_form.getValue(copiedFrom[i]));
    }
}

 

Regards,

JAS

View solution in original post

8 REPLIES 8

JODY8
Tera Expert
I would think this could be done in an onChange client script for the yes/no field. When user changes value, form fields are copied from one to another.

Joshwa Antony S
Mega Guru

Hi,

 

Create onChange client script that run when the Yes selected in Yes/No field.

Keep the script like this

//check field name and change

var copiedFrom = ['name', 'address', 'country'];
var copiedTo = ['other_name', 'other_address', 'other_country'];


if (newValue == 'yes') {
    for (var i = 0; i < copiedFrom.length; i++) {
        g_form.setValue(copiedTo[i], g_form.getValue(copiedFrom[i]));
    }
}

 

Regards,

JAS

Thank you Antony. It worked great.

Glad it worked!

Regards,

JAS