Skip to main content
Known Participant
April 17, 2023
Question

Spawn a hidden template when 2 conditions are met.

  • April 17, 2023
  • 3 replies
  • 3679 views

I have a multipage form that spawns hidden templates when a single check box is checked. I would like to spawn a different hidden template when two conditions are met. One would be a checkbox and the other based on the value of a cell. I have no idea where to start.  Is this possible?

This topic has been closed for replies.

3 replies

JR Boulay
Braniac
April 17, 2023

You can use this as a calculation script in the text field (replace the name of the checkbox):

if (this.getField("CHECKBOX").value != "Off") && event.target.value == "BC" || "AB" || "SK" || "MB" || "ON") {
// Spawning script
}

Acrobate du PDF, InDesigner et Photoshopographe
try67
Braniac
April 17, 2023

You can't use the OR operator like that. You have to specify both parts of the comparison each time, in full.

Alternatively, you can use an array of strings and the indexOf method.

try67
Braniac
April 17, 2023

Can you provide the statement for me?  I'm so new to this that I don't know what an array of string or an indexOf method statement would look like


if (this.getField("CHECKBOX").value != "Off" && ["BC", "AB", "SK", "MB", "ON"].indexOf(event.target.value)!=-1) {

JR Boulay
Braniac
April 17, 2023

What is the expected value in the cell (text field)?

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
April 17, 2023

It would be one of the abreviation of one of the provinces.  BC, AB, SK, MB, ON...

 

Known Participant
April 17, 2023

Or, can I have hidden templates first unhide with all possible choices and then when the second text field is filled in that it would hide the unwanted templates?

 

ls_rbls
Braniac
April 17, 2023

Hi @Barbara27752637tepn ,

 

Are you currently using a script?

 

If so, do you mind sharing the script?

 

Both cases are doable, but in my personal opinion I consider the first approach to be the easiest because you can incorporate a custom keystroke script with a condition that evaluates if the desired checkbox is checked, and you may run this custom keystroke script from the textfield where the user input is required.

 

However, I think that the tricky part is to figure out what do you want the PDF to do if, for example, the chexkbox is cleared or the filled-in data that was entered in the required field is deleted by the user.

 

In which case, you can instruct an additional condition in that script to handle the removal of the spawned page from the hidden template when such conditions are met.

 

 

Known Participant
April 17, 2023

The attached is the form I've developed so far.  There are a lot of moving parts.  We have to have a client sign a risk disclosure statement if they are wanting to purchase a certain security and it is different disclosure per province. If they click on non-disc (top right side of the page) and then when they select their home province in the address section, that is what needs to trigger the appropriate risk disclosure statement and unhide the template (yet to be made).