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
  • 2824 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 8, 2016

Thanks J,

Sounds simple enough, I will give it a try on Monday.

Rob

Sent via the Samsung Galaxy Note5, an AT&T 4G LTE smartphone