Copy link to clipboard
Copied
Hello All,
In my form I have a dropbdown box, where the user should choose one option. According the choice of the dropdown box a picture field should be displayed or hidden.
I used following calcualtion script:
if (event.value == "0")
{
this.getField("00").display = display.visible;
this.getField("11").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "1")
{
this.getField("11").display = display.visible;
this.getField("00").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "2")
{
....etc.
On the spawned template page I have an identical dropdown box and picture filds. However during spawning, field names are renamed and the calcualtion script doesnt work anymore. Any idea how to modify the calculation script in a way, that it also will work on spawned template pages? As my form has other textfields (which need to be renamed during spawning pprocess) expTplt.spawn(numPages,false,false); doesnt seem to be the solution. There should be somehow a way to modify the calculation script of the dropbox!?
Thanks in advance for your support.
Copy link to clipboard
Copied
Have you noticed any pattern to the naming of the fields?
When I build a template, I use the template to spawn the first page. This usually means I need to rename the fields to start with "P0.". I then hide the template and work on the field names. By using the '"vent.target.name" property I can get the full field name as a variable and then I can use the "split()" method to convert the hierarchical field name into an array of the levels. The first element will be of the format "P#" where # is the number of times any template has been spawned. The second element is the template name. And the remaining elements are the parts of the field name on the template. It is possible with this information to "compute" the names of the field on a page from within most fields on that page. The exception is if a template is overlayed on the page without renaming the fields.
Copy link to clipboard
Copied
Hello gkaiseril, many thansk for your answer. Thant means I could modify the calculation script with using '"vent.target.name"?
If yes, how I need to modify the o.m. script? Sorry for my question. Unfortunately I am not a scripting specialist. ![]()
Best regards
Florian
Copy link to clipboard
Copied
It should be event.target.name. This will give one the name of the field that currently has the focus or is being accessed. From this one should be able to get the "P#" and the template name values which have been affixed to each renamed field.
Copy link to clipboard
Copied
Hello gkaiseril, many thansk for your answer. That means, I have to change the validation in following way?
if (event.value == "0")
{
this.getField("P#00").display = display.visible;
this.getField("P#11").display = display.hidden;
this.getField("P#22").display = display.hidden;
this.getField("P#33").display = display.hidden;
this.getField("P#44").display = display.hidden;
this.getField("P#55").display = display.hidden;
this.getField("P#66").display = display.hidden;
this.getField("P#77").display = display.hidden;
this.getField("P#88").display = display.hidden;
}
Copy link to clipboard
Copied
Hello can anybody answer my question?
Copy link to clipboard
Copied
..Explain how tom work with the funtion "event.target.name."?
Copy link to clipboard
Copied

I have 1 PDF page whi is the template. It has one dropdown box, where in accordance to the dropdown box value is shown a picture. After spawning this template page, names of picture filds are changed and the dropbox is not working anymore.
gkaiseril, mentioned that there is one waz to solve this problem: event.target.name. This will give one the name of the field that currently has the focus or is being accessed. From this one should be able to get the "P#" and the template name values which have been affixed to each renamed field.
Is there anybody out here, who could explain me who to change the scripting?
if (event.value == "0")
{
this.getField("00").display = display.visible;
this.getField("11").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "1")
{
this.getField("11").display = display.visible;
this.getField("00").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "2")
{
....etc.
Copy link to clipboard
Copied
In my first post I provided a link to an article that explains how the fields are named. It is old but it is still how fields on a spawned template are renamed.
You can see this if you spawn a new page from a template with the rename parameter set to true and then open the form in the Prepare Form and look at the names of the fields on the spawned page.
Copy link to clipboard
Copied
I understood that during the spawning perocess field names are changed. But i still dont understand how to change the validation script in the dropbox. As I dont know how many time the form will be spawned, Is there any variable, wchich condiders the name changing of fields?
if (event.value == "0")
{
this.getField("00").display = display.visible;
this.getField("11").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "1")
{
this.getField("11").display = display.visible;
this.getField("00").display = display.hidden;
this.getField("22").display = display.hidden;
this.getField("33").display = display.hidden;
this.getField("44").display = display.hidden;
this.getField("55").display = display.hidden;
this.getField("66").display = display.hidden;
this.getField("77").display = display.hidden;
this.getField("88").display = display.hidden;
}
else if (event.value == "2")
{
....etc.
Copy link to clipboard
Copied
Only if you compute the name string from your knowledge of the form and focused field name .
For example, if I have an order form and the template's name is "NewPage". The template has fields named "Quanity", "Price", and "Total". When I spawn a new page, the new page will have the 3 fields but if I have one displayed page the spawned page will be page 2 and the field names will be prefixed with "P1.NewPage." or the fields names will be "P1.NewPage.Quantity", "P1.NewPage.Price", and "P1.NewPage.Total". If I have a custom Calculation script in the "P1.NewPage.Total" field I can obtain the name of the that specific field by using "event.target.name". If I put that string into a variable "cFieldName" I can convert that string using the "split" method into an array of 3 elements. Element 0 is "P[number]", element 1 is "NewPage" or template name, and element 3 is "Total". Elements 0 and 1 will provide the add suffix values.
A script can be used to compute the prefix for the field names:
// compute field name prefix;
function getFieldPrefix(cFieldName)
{
// get field name;
var cFieldName = event.target.name;
// field name as an array;
var aFieldName = cFieldName.split(".");
// declare prefix variable;
var cPrefix = "";
// test if template/overlay or spawned page with renamed fields;
if(aFieldName.length > 2) {
// create value for cPrefix variable;
cPrefix = aFieldName[0] + "." + aFieldName[1] + ".";
} // end more than 2 elements;
return cPrefix;
} // end FieldPrefix function;
// calculation;
var cPrefix = getFieldPrefix(event.target.name);
event.value = this.getField(cPrefix + "Quantity").value * this.getField(cPrefix + "Price").value;
Note that this script determines if the page is a template or a spawned page.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more