calculated fields (javascript) not updating when a page is deleted
Copy link to clipboard
Copied
I have a summary page that shows some calculated fields and text that get their values from other pages (order forms). The 'order form' pages are spawned, and so a customer can create multiple orders (multiple pages) and can also delete a page. The javascript on the summary page is not updating if one of order form pages is deleted. Is their a script to refresh javascript if a page is deleted or something that would help?
Copy link to clipboard
Copied
this.calculateNow() ;
Copy link to clipboard
Copied
I have tried this and it does not work.
Copy link to clipboard
Copied
Do you mind sharing your script?
Copy link to clipboard
Copied
var strName;
var nSumEnrollmentFee = 0;
for(var i=0;i<this.numFields;i++)
{
strName = this.getNthFieldName(i);
if(/Enrollment_Fee$/.test(strName))
{
oFld = this.getField(strName);
if(oFld.page >=0)
nSumEnrollmentFee += oFld.value;
}
}
event.value=nSumEnrollmentFee;
this.calculateNow();
________________________-
I've tried using this.calculateNow(); both at the beginning and end of the script. When a page is deleted that this script gets information from, it does not update.
Copy link to clipboard
Copied
Use this.calculateNow(); after the page delete.
Copy link to clipboard
Copied
I have not yet added a button for deleting a page, but will, and will definately add the script there. That part has already occurred to me. My issue is that some people will use an adobe version that will allow them to see the pages in the navigation pane and subsequently they will delete the page from here. This is where the problem lays - when the page is being deleted from the navigation pane.
Copy link to clipboard
Copied
There's nothing you can do about that, as deleting a page (manually) does not trigger any event you can use to run a script. However, you can use the Page Open event of all the pages in your file. For example, you can save the number of pages in the file when it is first opened to a doc-level variable, and then add a script to the Page Open (and/or Page Close) event of each page comparing that number to the current number of pages. If they don't match, call calculateNow (and maybe update the value of this variable, to avoid unnecessary calculations later on).
Copy link to clipboard
Copied
Where does you use the script?

