Skip to main content
Participant
Apr 29, 2025 3:37 PM UTC
Answered

Spawn templates based on drop down selection

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!

PDF Automation Station
Community Expert
Apr 30, 2025 6:09 PM UTC

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?

4 replies

PDF Automation Station
Community Expert
Community Expert
Apr 29, 2025 4:12 PM UTC

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?

Translate
Participant
Apr 30, 2025 5:56 PM UTC

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.

Translate
PDF Automation Station
Community Expert
Community Expert
Apr 30, 2025 6:09 PM UTC

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?

Translate