The CreatorCon Call for Content is officially open! Get started here.

Glide modal: Change textarea field dynamically based on another field value

OtaS2209
Tera Contributor

Hello, I am learning a Glide Modal on the Agent Workspace. I can put some fields there and do the work when submitting it.

 

But, I would like to have the option we are having on forms with onChange() client script. When I write something in the first field, I would like to have it written dynamically in another. Something like on the screen:

 

Screenshot_37.png

 

I assume it would be something simple, but I haven't figured it out. Could you hint to me a little? Thank you

1 REPLY 1

OtaS2209
Tera Contributor

Oh, I see that I didn't provide you with the script. Here it is:

 

function onClick(g_form) {

    var fields = [{
        type: 'textarea',
        name: 'subject',
        label: getMessage('Adjust the subject'),
        mandatory: true,
		value: 'Something...'
    }];
	
	fields.push({
		type: 'textarea',
        name: 'readonly_subject',
        readonly: true,
        label: getMessage('Your subject is'),
        mandatory: true,
		value: fields[0].value
	});

    g_modal.showFields({
        title: "The Email",
        fields: fields,
        size: 'lg'
    }).then(function(fieldValues) {
        alert(fieldValues.updatedFields[1].value);
        g_form.save();
    });
}