Skip to main content
Participant
April 29, 2025
Answered

Spawn templates based on drop down selection

  • April 29, 2025
  • 1 reply
  • 592 views

Hello, I currenly have buttons on my PDF that, when selected, will generate a template after the current page. I want to switch this to a drop down list so it doesn't crowd the PDF. Would someone be able to help me with this? As an example, I have 3 drop down items (MT, UT, RT), when I select one, I want the appropriate template to spawn. The templates are names the same as the drop down item selections. Any help would be greatly appreciated! Thank you!

Correct answer PDF Automation Station

numPages should have an upper case P.  The script should be:

this.getTemplate(event.value).spawn(this.numPages,true,false);

Does your dropdown have export values?

1 reply

PDF Automation Station
Community Expert
Community Expert
April 29, 2025

In the dropdown options tab select "Commit selected value immediately", then write a custom validation script the same as your button sript, but use event.value as the name of the template.  Do you want the spawned pages deleted if the user THEN selects a different value in the dropdown, or do you want it to keep spawning templates without deleting previous ones?

Participant
April 30, 2025

Hello, thank you! I would like it to keep spawning templates without deleting previous ones. My current code for the buttons is this:

getTemplate("MT").spawn(this.numpages, true, false);

I tried replacing the template name to event.value and it does nothing.

PDF Automation Station
Community Expert
Community Expert
April 30, 2025

numPages should have an upper case P.  The script should be:

this.getTemplate(event.value).spawn(this.numPages,true,false);

Does your dropdown have export values?