Skip to main content
Participating Frequently
August 22, 2018
Answered

Spawn different page templates from dropdown

  • August 22, 2018
  • 1 reply
  • 1615 views

Hi I'm currently trying to make a pdf spawn different page templates based on the selections from a dropdown and I can't seem to get it to work:

I have the drop down named "Brief Type 3" containing 5 items with export values from 1-5. I also have a button to receive these values.

I have 5 page templates named 'spawn1', 'spawn2' 'spawn3' 'spawn4' 'spawn5'.

I'm using the following:

var sel = this.getField("Brief Type 3").value;

var templateName = "";

switch (sel) {

    case 1 : templateName = "spawn1";

        break;

    case 2 : templateName = "spawn2";

        break;

    case 3 : templateName = "spawn3";

        break;

    case 4 : templateName = "spawn4";

        break;

    case 5 : templateName = "spawn5";

        break;

}

if (templateName != "") {

    var t = this.getTemplate(templateName);

    t.spawn();

}

What am I doing wrong??

Any help would be greatly appreciated.

Thanks

Sam

This topic has been closed for replies.
Correct answer try67

Then you need to change this:

t.spawn();

To something like this:

t.spawn({nPage: event.target.page+1, bOverlay: false});

1 reply

try67
Community Expert
Community Expert
August 22, 2018

Where did you place the code?

Are there any error messages when you run it?

If you don't specify any parameters for the spawn method it will spawn the template over the existing first page of the file. It won't create a new page. Is that what you want to happen?

Participating Frequently
August 22, 2018

Hi, I placed the code on a mouse up on the OK button, I'd like all spawned pages to go after the page that is generating it, i.e. the one with the dropdown/ok button.

Thanks

Sam