Copy link to clipboard
Copied
Joel_Geraci helped me massively on this project already, but now I have a question that doesn't fit my earlier discussion.
I am using javascript and page templates. I have a button that spawns a new narrative page and all of the fields get renamed with that new page number to prevent text from duplicating.
However there is one field, "PageTotal" that I don't want to be changed at all even when spawned from a template. I want to be able to type "5" and it be duplicated across all of the pages. What I would end up with is Page X of 5.
Any ideas what the javascript exemption would be so I can spawn the page, but prevent just that one field ("PageTotal") from turning into "P2.Narrative.PageTotal"?
Okay everyone, I was able to get it to work. Below is the solution that I compiled from both this thread and the one that JR_Boulay posted above.
All I needed to do was add "event.value = this.numPages;" (the stuff within quotes) to the "PageTotal" field on both the static and template pages. That's it!
I also used "event.value = (event.target.page + 1);" to populate the individual page number boxes.
Thank you all for your input!
Copy link to clipboard
Copied
There is no such exemption. What you can do is spawn it with the renamed
fields, then delete them and add copies of the original field on the new
pages.
Copy link to clipboard
Copied
Hi.
You should not care about the name of this text field, you should use a script as explained here: Re: Template page number
Copy link to clipboard
Copied
JR_Boulay wrote
Hi.
You should not care about the name of this text field, you should use a script as explained here: Re: Template page number
Unfortunately this does not cover what I need in this post, however this might help me with another task I was considering. Thank you!
Copy link to clipboard
Copied
try67 wrote
There is no such exemption. What you can do is spawn it with the renamed
fields, then delete them and add copies of the original field on the new
pages.
That defeats the purpose of the form. I don't want anyone to have to modify the form, I want to get the work done on my end. No one else (well, very few others) are knowledgeable on how to create or modify forms.
Copy link to clipboard
Copied
I don't understand what you mean... You're using a script to spawn the pages, no? Then you can use the same script to do what I've described. How are the two things different?
Copy link to clipboard
Copied
Jumping in again... the spawned field names are completely predictable and based on their original name. It'll be easy to locate and modify any of the newly added fields.
Copy link to clipboard
Copied
Joel_Geraci wrote
Jumping in again... the spawned field names are completely predictable and based on their original name. It'll be easy to locate and modify any of the newly added fields.
Right, but again, this form is being made to be as simple to use as possible, i.e. no one would ever have to modify the form.
Copy link to clipboard
Copied
try67 wrote
I don't understand what you mean... You're using a script to spawn the pages, no? Then you can use the same script to do what I've described. How are the two things different?
Via the click of a button to activate the script. If I understand your initial suggestion, they would click the button to spawn the page, then have to modify the form itself by deleting that one field and copying the original. Is this correct?
Copy link to clipboard
Copied
Via the click of a button to activate the script. If I understand your initial suggestion, they would click the button to spawn the page, then have to modify the form itself by deleting that one field and copying the original. Is this correct?
No. The same click on the button can be used to do what I've described (ie, delete the duplicate fields, add the new ones), after you've spawned the pages.
Copy link to clipboard
Copied
try67 wrote
Via the click of a button to activate the script. If I understand your initial suggestion, they would click the button to spawn the page, then have to modify the form itself by deleting that one field and copying the original. Is this correct?
No. The same click on the button can be used to do what I've described (ie, delete the duplicate fields, add the new ones), after you've spawned the pages.
Ahhh ok I understand now, but I was overthinking the problem. Found a simple solution that works for this (posted above).
Copy link to clipboard
Copied
Ones has 2 templates. One has the fields to be renamed and this page is spawned with rename trkue and overlay false. The second template has the field not to be renamed and is spawned with rename false and overlay true.
Copy link to clipboard
Copied
gkaiseril wrote
Ones has 2 templates. One has the fields to be renamed and this page is spawned with rename trkue and overlay false. The second template has the field not to be renamed and is spawned with rename false and overlay true.
I played with this and it created two pages, but it was not the result I wanted...
Copy link to clipboard
Copied
George, that's what I was thinking to do. Keep all fields you want to rename on one template but have a second template that spawns with bRename and bOverlay as true.
if you want everything to spawn on page 2 it would be something like:
this.getTemplate("templateNameHere").spawn(1, true, true);
Copy link to clipboard
Copied
Great tip George!
Copy link to clipboard
Copied
Replying to my original post in hopes that everyone sees this...
Would it be possible instead to write a script that, say, finds all of the spawned fields and renames them?
For example, the field in question is named "PageTotal" and when spawned, turns into "P2.Narrative.PageTotal" or "P3.Narrative.PageTotal" where "Narrative" is what I named by template.
So I would need the script to find all of the P2, P3, and on boxes and rename them back to PageTotal.
Possible? Or no lol.
BTW I appreciate all of the input I am getting. This is really helping me further understand coding.
Copy link to clipboard
Copied
Maybe you first need to examine a example of a working PDF of an invoice that can add additional pages and total the purchases on the page.
https://www.dropbox.com/s/cnkdvq8znfg5nga/SimpleTemplate.pdf?dl=0
Copy link to clipboard
Copied
Okay everyone, I was able to get it to work. Below is the solution that I compiled from both this thread and the one that JR_Boulay posted above.
All I needed to do was add "event.value = this.numPages;" (the stuff within quotes) to the "PageTotal" field on both the static and template pages. That's it!
I also used "event.value = (event.target.page + 1);" to populate the individual page number boxes.
Thank you all for your input!
Copy link to clipboard
Copied
I found this old discussion trying to figure out the same thing, and to be honest, the correct answer marked in this thread is a workaround that does not addresses the original inquiry.
I am struggling with a row of six text fields and a hidden image field that I must keep with the same field name after spawning the pages as it appears in both the source document page and the template page because of the dependent fields calculations.
I need these six fields not to be pre-fixed after the spawning is executed.
For example, I have a button with a mouse up event script that will take the values from only one field in the source document and populate the other five fields next to it with different chunks of data extracetd from the source field object of the main document.
This is a PDF project that try67 has been assisting me with since I joined the forums about a year ago, and spawining is the last phase of this project.
These are government forms and each of the spawned forms has to be digitally signed individually which is extremely time consuming for the approver who has to sign over 10, 15 or more of these forms one by one.
The idea is to click on that button and extract the distinguished name of the digital certificate to one field, the signature date to another field, the common name of that certificate with the EDIPI number to another field, and the hidden image field to become visible when this button is clicked.
I already have this working fine and great. But as the spawned pages rename all the fields I end up loosing that functionality for those fields on each spawned page.