Copy link to clipboard
Copied
Looking for information on how to use JavaScript with form fields create from a form template. I don't know how to get the form field names as they change when they are create from a template.
Thanks
The simplest way to do it is to apply the following custom calculation script to this field:
if (event.target.name!="P3.CA PG 1 TEMP.recipient") event.value = this.getField("P3.CA PG 1 TEMP.recipient").valueAsString;
Copy link to clipboard
Copied
The names of spawned form fields are predictable. They contain the template name, the new page number and the original field name.
Copy link to clipboard
Copied
I have multiple template pages within this form. I have added buttons that allow the user to put different pages in different locations in the form. Example: This field "P3.CA PG 1 TEMP.recipient" can appear on multiple pages. I want to use JavaScript to transfer the value entered on page one to the other field(s) create on all other template pages.
Copy link to clipboard
Copied
The simplest way to do it is to apply the following custom calculation script to this field:
if (event.target.name!="P3.CA PG 1 TEMP.recipient") event.value = this.getField("P3.CA PG 1 TEMP.recipient").valueAsString;
Copy link to clipboard
Copied
Thanks, that helps. I have one more question. Keep in mind that this template page can appear on any page. I have a button "P3.CA PG 1 TEMP.addRCCode" that call this function "addRCCode". The function pulls the value from this field "RCCodeMenu" and puts it in this field "RCCodeText". Is there a way to call these fields using just the last part of the fields name (Example ".RCCodeText")? I am sorry for being a Nuisance. Thanks again.
function addRCCode()
{
var r = this.getField("RCCodeMenu").value;
var s = this.getField("RCCodeText");
var stext = this.getField("RCCodeText").value;
if (stext == ""){
s.value = (stext + r);
}
if (stext != ""){
s.value = (stext + " , " + r);
}
}
Copy link to clipboard
Copied
The field name is just a string. You can manipulate it just like any other string. You can split it, replace parts of it, etc.
Copy link to clipboard
Copied
Can you provide an example of how to do that?
Copy link to clipboard
Copied
I found that that by setting the spawn command to false the template will keep there original names. Sorry to be so much trouble.
spawn(this.numPages,false,false);
Thanks again Try67.