Combining calculations with spawning pages is quite a complex task. You basically need to write a script that looks up the fields to use in the calculation, because you can't know in advance what their names are going to be.
So what is the calculation that you'd like to perform? The field name of a calculated field will have the same prefix (e.g, P2.Mod_A_P_A_1) as the other fields on the page and can be retrieved in the script using the event.target.name property. For example:
// Split this field's name at the periods
var fna = event.target.name.split(".");
// Get the field name prefix of all fields on the page
var fp = fna.length > 1 ? fna + "." + fna + "." : "";
// Perform a simple calculation
event.value = getField(fp + "text1").value - getField(fp + "text2").value;
Thank you both for responding, your help as usual is greatly appreciated.
@George: the calculation is really simple, just a sum of these specific fields... I tried to run your script and... it works!
Guess I say that code somewhere else in the forum when searching, but as I dont understand all the syntax, I could not get it to work...
Thank you so much for all the help guys!
When a new page is spawned form a template and the fields are renamed, the field names from the template are changed to include a prefix of the page number and the template name. It is up to the developer to have the code adjsut for these changes either in the form fields or in the document level functions.
1 person found this helpful
Thanks a lot for the help, guys! I was able to get it to work after your kind guidance!