Confirmation Checkboxes

New Here ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

264

Likes

Translate

Translate

Report

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

correct answers 1 Correct Answer

Adobe Community Professional , Nov 11, 2020 Nov 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 app...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

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  

Likes

Translate

Translate

Report

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
New Here ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Hi

 

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

 

Gary

Likes

Translate

Translate

Report

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
New Here ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

ls_rbls

 

Thank you for your help. I finally got back to it.

 

I modified the script to reflect the actual hidden template page names as follows:

 

// 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("Page6").spawn(1, false);
this.getTemplate("Page7").spawn(2, false);

app.alert("When ready please complete Re-assesment pages (Page 6 and Page 7)", 1);

}

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

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

}

 

When I use this on the checkbox it asks me to respond 'Yes' or 'No' but when I activate 'Yes' the pages do not appear. I have checked the hidden template page names and they are correct.

 

Are you able to assist further?

 

Gary

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

Sure, 

 

would you mind sharing the file back with your changes so I can take a closer  look at it?

Likes

Translate

Translate

Report

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
New Here ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

Sorry

Not sure what the file back is you are referring to. The script I am using I posted previously.

Gary

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

I posted for you a working PDF with examples in it with both radio buttons and checkboxes so you can test how is working.

 

is the link "NYC PDF", I think you missed it.

 

 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

Never mind, I think I know.

 

I ran the script from the No  radio button.. It unchecks itself automatically, check the "Yes" radio button and if it finds the pages it will  delete them.

 

Likes

Translate

Translate

Report

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
New Here ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

Hi

 

Worked it out. I didn't change the spawn page numbers and have corrected the issue. It now works.

 

Thank you very much.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

LATEST

You're welcome.

Likes

Translate

Translate

Report

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