Skip to main content
Participating Frequently
October 7, 2016
Answered

I need to disable a button after it has been clicked and spawned a template

  • October 7, 2016
  • 1 reply
  • 2797 views

I have little experience writing java script, but I am pretty sure I need to use java script to disable an add page button after it has been clicked and spawned it's assigned template. The java script I am using to spawn the template is as follows.

var expTplt = getTemplate("tpltReport");

expTplt.spawn(2,true,false);

This script works fine, and I have created several identical templates with different names so that a specific template is launched when the add page button is clicked on specific page of the pdf. This is to prevent the information that is entered on one page from being repeated on all the subsequent pages that are added to the pdf. I rename the effected fields on each template to accomplish this.

Since each template has its own add page button, with the exception of the final template, if one is clicked multiple times from the same page it will spawn multiple identical pages and the repeating information error will occur.

Any simple solutions?

This topic has been closed for replies.
Correct answer JoelGeraci_Datalogics

Add the following line to the end of your script so so that the button being pressed is the one that runs the script. Setting a button to read-only makes it disabled. The event is the click, the target is the object that triggered the event... in your case, the button, regardless of the number of times it gets renamed due to the spawn process.

event.target.readonly = true;

J-

1 reply

JoelGeraci_Datalogics
JoelGeraci_DatalogicsCorrect answer
Participating Frequently
October 7, 2016

Add the following line to the end of your script so so that the button being pressed is the one that runs the script. Setting a button to read-only makes it disabled. The event is the click, the target is the object that triggered the event... in your case, the button, regardless of the number of times it gets renamed due to the spawn process.

event.target.readonly = true;

J-

Participating Frequently
October 10, 2016

HI Joel,

I am getting a syntax error (SyntaxError: missing ; before statement 3: at line 4).

Below is how the string reads after adding your suggestion at the end of the script. Maybe I am not understanding what your are telling me to do.

var expTplt = getTemplate("tpltReport");

expTplt.spawn(2,true,false);

click.Add Page1.readonly = true;

Thoughts?

Best regards,

Rob Kerr

Technical Writer

[ Mod: Personal information removed ]

Participating Frequently
October 10, 2016

I'm not sure what "auto spacing" you're referring to, but the code above does not have any syntax errors in it.


The auto spacing seems to only exist in the email, which is where I copied Joel’s original code from before pasting it into the javascript window in Acrobat.

This is the only explanation I can easily come up with for the syntax error I was getting since it seems that I was placing the string into the code correctly. Regardless I did a test and typed the code in and pasted Joel’s code from the online thread with no issues. I then copied and from his email and from your email and got the same syntax error, but it also worked once in awhile.

This issue is resolved and I have the form doing what I need it to do.

Thanks for your help on this.

Best regards,

Rob Kerr

Technical Writer

[ Mod: Personal information removed ]