Skip to main content
kehumphr
Inspiring
February 16, 2017
解決済み

Using a page template and spawn, but I don't want one particular field to be renamed to the new page...

  • February 16, 2017
  • 返信数 6.
  • 5447 ビュー

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"?

このトピックへの返信は締め切られました。
解決に役立った回答 kehumphr

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!

返信数 6

ls_rbls
Community Expert
Community Expert
February 24, 2021

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.

kehumphr
kehumphr作成者解決!
Inspiring
February 16, 2017

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!

kehumphr
kehumphr作成者
Inspiring
February 16, 2017

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.

Inspiring
February 16, 2017

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

Sample Template PDF

JR Boulay
Community Expert
Community Expert
February 16, 2017

Great tip George!

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
February 16, 2017

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.

kehumphr
kehumphr作成者
Inspiring
February 16, 2017

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...

try67
Community Expert
Community Expert
February 16, 2017

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.

JR Boulay
Community Expert
Community Expert
February 16, 2017

Hi.

You should not care about the name of this text field, you should use a script as explained here: Re: Template page number

Acrobate du PDF, InDesigner et Photoshopographe
kehumphr
kehumphr作成者
Inspiring
February 16, 2017

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!