Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Spawn a hidden template when 2 conditions are met.

Community Beginner ,
Apr 17, 2023 Apr 17, 2023

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?

TOPICS
JavaScript , PDF forms
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 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?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 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.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 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).

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 17, 2023

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


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 17, 2023

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 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 Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 17, 2023

Thank you!  I'll give that a try. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 17, 2023

Actually, there is one more challenge.  Not always when the province is selected does it need to have a risk disclosure statement. Only when the checkbox in the top right corner, Non-DISC is checked does a risk disclosure need to be generated and the type is dependant on the province. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 17, 2023

Sorry. I see where it takes that into account... Oops. My bad

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 17, 2023 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 17, 2023
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines