Skip to main content
warm_Lullaby5CA0
Known Participant
September 8, 2017
Answered

display page template after checkbox is ticked

Hoping someone can assist me, I am developing a acrobat form and am struggling a little bit! Basically I want the user to tick a checkbox and then click a button. If the checkbox is ticked when the button is pushed then the form should add a page template. At the moment I have the below code for this part however when I preview the form, it doesn't matter whether if the checkbox is selected or not selected, it spawns the page template anyways. This makes me think that there is something not right about my if statement. Can someone explain what I am doing wrong here?

*Advice is the name of the checkbox item.

var advice = this.getField("Advice");

if (advice = "true")

{

var advicePage = this.getTemplate("advice");

advicePage.spawn(this.numPages, true, false);

}

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
September 11, 2017

Shared Files - Acrobat.com


You must use the value of the check box:

var advice = this.getField("Advice").value;

12 replies

Bernd Alheit
Community Expert
Community Expert
September 8, 2017

Use:

if (advice == "true")

not:

if (advice = "true")

Translate
warm_Lullaby5CA0
Known Participant
September 8, 2017

Now it does not spawn the page at all (whether the checkbox is ticked or not).

Translate
Bernd Alheit
Community Expert
Community Expert
September 8, 2017

What is the export value of the checkbox?

Translate