Want to insert value on read only field when

TejasviR
Tera Contributor

Hello all,

I have 4 fields 1- Org name, 2- Name (read-only), City, and description on my form. When the user clicks on the submit button, Value from Org Name will copy into the Name field.

 

I really appreciate any help you can provide.

1 ACCEPTED SOLUTION

Sai Kumar B
Mega Sage
Mega Sage

@TejasviR 

Why submit? You can try the same with the onChange client script

1.) Write onChange client script on org name field with the below script

2.) By using the below script, Whatever you input in the org name same populates in the name field as well

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

if(newValue){
g_form.setValue('name', newValue) //set name field with newValue, newValue is org name value
}

}

View solution in original post

4 REPLIES 4

Sai Kumar B
Mega Sage
Mega Sage

@TejasviR 

Why submit? You can try the same with the onChange client script

1.) Write onChange client script on org name field with the below script

2.) By using the below script, Whatever you input in the org name same populates in the name field as well

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

if(newValue){
g_form.setValue('name', newValue) //set name field with newValue, newValue is org name value
}

}

Hello

@Sai Kumar,

Thank you for your answer.

I am already using the onChange client script on Org name, that's why I want to perform this task on submit, I know I can change the order, but for the safe side want to try on onSubmit. 

Since you already have an OnChange() script for Org name why not add a line to make it work in the same script itself. No need of separate onSubmit() as it will work as expected even onChange() & suffice your need.

Okay. Thank you @Jaspal Singh