confirmation popup when generating list (Acrobat Pro)

Community Beginner ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Hello

 

I have a button which generates a list in a text field using the following script (on mouse down):

 

var total = ""; for(var i=1; i<=92; i++){ if(this.getField("priority"+i).valueAsString != "Off") total+="• "+this.getField("Text"+i).valueAsString+"\n";} this.getField("summary").value = total

 

I want to have a confirm popup (which I’m assuming will be along the following lines):

 

if(4==app.alert("Retrieve opportunities and skills priorities?",1,2))

 

How do I combine these scripts so that when the user clicks “no” to the popup message, the “summary” field remains unaltered? (i.e. any text already in “summary” does not update).   

 

Many thanks

 

Mark

TOPICS
Create PDFs

Views

109

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

Most Valuable Participant , Feb 15, 2021 Feb 15, 2021
Just combine the two codes... Like this: if(4==app.alert("Retrieve opportunities and skills priorities?",1,2)) { var total = ""; for(var i=1; i<=92; i++){ if(this.getField("priority"+i).valueAsString != "Off") total+="• "+this.getField("Text"+i).valueAsString+"\n";} this.getField("summary").value = total }

Likes

Translate

Translate
Most Valuable Participant ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Just combine the two codes... Like this:

 

if(4==app.alert("Retrieve opportunities and skills priorities?",1,2)) {

var total = ""; for(var i=1; i<=92; i++){ if(this.getField("priority"+i).valueAsString != "Off") total+="• "+this.getField("Text"+i).valueAsString+"\n";} this.getField("summary").value = total

}

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
Community Beginner ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Thanks! I was missing out the "}" when i orignially tried combining.  

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
Most Valuable Participant ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

In that case it should have given you an error message, like this:

 

SyntaxError: missing } in compound statement
3:Console:Exec

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
Community Beginner ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

I'd missed both "{" and "}", so it was running, but pulling the list through regardless of what option was selected from the popup.  All new to me, so figuring it out as i go.  If I can be cheeky, could you also advise on a related issue? On a second confirmation popup, i have the following script: 

 

if(4==app.alert("This action will clear the form.\nDo you want to continue?",1,2)) { this.getField("see").display = display.visible; this.getField("see").display = display.hidden; this.getField("add").display = display.visible; this.getField("add").display = display.hidden; this.resetForm(); }

 

But i'd also like to reset (turn white) the fill colour of a field following confirmation of the same popup.  It’s probably simple, but I can’t quit figure out how I’d integrate the following script:

this.getField("coll").event.target.fillColor = color.white;

 

thanks, Mark 

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
Most Valuable Participant ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Use this:

this.getField("coll").fillColor = color.white;

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
Community Beginner ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

LATEST

Thats great, thanks. 

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