Skip to main content
Participating Frequently
November 11, 2020
Answered

Confirmation Checkboxes

  • November 11, 2020
  • 2 replies
  • 3144 views

I am currently designing a form in Acrobat Pro with Javascript providing the required functionality. The form has 7 pages with two hidden as templates.

 

I have two paired checkboxes Competent and Not Yet Competent (NYC). When the NYC checkbox is selected I want the twp hidden template pages to appear but I also want to alert the person that by selecting the NYC the pages will appear and do they wish to proceed. If they select 'Yes' then the checkbox will be ticked and pages will appear. If they select 'No' then the checkbox will not be ticked and the pages will not appear.

I am using the follow script:

 

event.target.checkThisBox(0, app.alert("By selecting this checkbox the Re-assessment pages at the bottom of this document will appear for re-assessment purposes. To remove the Re-assessment pages select the Competent or Satisfactory checkbox to the left.\n\nCheck this box?",2,2)==2);

 

this.getTemplate("Page6").

spawn(5);

 

this.getTemplate("Page7").

spawn(6);

 

My issue is that if a person selects 'No' then the template script still runs and the pages appear which I don't want if  'No' is selected. This has to work in Reader as most of my customers only have Reader DC.

 

I am not new to Java but I am no expert by any means so any assistance would be appreciated.

This topic has been closed for replies.
Correct answer ls_rbls

Please disregard my previous answer. I documented myself better.

 

I didn't answer how to remove the pages that were spwaned and I also didn't cover a few other details in that script.

 

Below is  the refined version of the same script.

 

It works with both checkboxes and radio buttons, and I am using it as Mouse-up javascript event action in the radio button "No"

 

 

// DECLARE YOUR VARIABLES

var cMsg = "By selecting this checkbox the Re-assessment pages at the bottom of this document will appear for re-assessment purposes.To remove the Re-assessment pages select the Competent or Satisfactory checkbox to the left.";

cMsg += "\n\nDo you want to continue?";

var nRtn = app.alert(cMsg,2,2,"Question Alert Box");


// ESTABLISH IF CONDITIONS

if(nRtn == 4)
{// A yes Response

  // Code for doing the thing you do on a yes

(event.target).checkThisBox(1, true);
this.getTemplate("Page2").spawn(1, false);
this.getTemplate("Page3").spawn(2, false);

app.alert("Please complete Re-assesment pages (Page 2 and Page 3)", 1);

  }

if (nRtn == 3)
{ // No Response

(event.target).checkThisBox(0, true);
this.deletePages({nStart: 1, nEnd: 2 });

 }

 

 

In addition, you want to also add just this line  to the radio button"Yes":

 

 

this.deletePages({nStart: 1, nEnd: 2 });

 

 

Here's a working copy of the PDF that I am working on with this script: NYC PDF  

2 replies

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
November 11, 2020

Please disregard my previous answer. I documented myself better.

 

I didn't answer how to remove the pages that were spwaned and I also didn't cover a few other details in that script.

 

Below is  the refined version of the same script.

 

It works with both checkboxes and radio buttons, and I am using it as Mouse-up javascript event action in the radio button "No"

 

 

// DECLARE YOUR VARIABLES

var cMsg = "By selecting this checkbox the Re-assessment pages at the bottom of this document will appear for re-assessment purposes.To remove the Re-assessment pages select the Competent or Satisfactory checkbox to the left.";

cMsg += "\n\nDo you want to continue?";

var nRtn = app.alert(cMsg,2,2,"Question Alert Box");


// ESTABLISH IF CONDITIONS

if(nRtn == 4)
{// A yes Response

  // Code for doing the thing you do on a yes

(event.target).checkThisBox(1, true);
this.getTemplate("Page2").spawn(1, false);
this.getTemplate("Page3").spawn(2, false);

app.alert("Please complete Re-assesment pages (Page 2 and Page 3)", 1);

  }

if (nRtn == 3)
{ // No Response

(event.target).checkThisBox(0, true);
this.deletePages({nStart: 1, nEnd: 2 });

 }

 

 

In addition, you want to also add just this line  to the radio button"Yes":

 

 

this.deletePages({nStart: 1, nEnd: 2 });

 

 

Here's a working copy of the PDF that I am working on with this script: NYC PDF  

Gary55Author
Participating Frequently
November 12, 2020

Hi

 

Thank you very much for that. I have not had a chance to use it yet but will do soon.

 

Gary

ls_rbls
Community Expert
Community Expert
November 11, 2020

Hi,

 

Try it like this:

 

var cMsg = "Continuing with the current action will overwrite previous entries";
cMsg += "\n\nDo you want to continue?";

var nRtn = app.alert(cMsg,2,2,"Question Alert Box");
if(nRtn == 4)
{// A yes Response
  // Code for doing the thing you do on a yes

(event.target).checkThisBox(1, true);
//this.getField("NYC").checkThisBox(0,false);

this.getTemplate("Test1").
spawn(4);
this.getTemplate("Test2").
spawn(5);

}

else if(nRtn == 3)
{ // No Response

this.resetForm(["NYC"]);

}

 

I am using mutually exclusive radio buttons but I was able to run it with checkboxes.

 

I am also using this guidelines:https://acrobatusers.com/tutorials/popup_windows_part1/  by ACP Thom Parker.