Need javascript for button to set all fields to read only with pop up prompt

New Here ,
Mar 18, 2020

Copy link to clipboard

Copied

Hi, 

As a newbie, I'm stuck.  

This is as far as I could get in setting up a "Done" button to lock all the fields as read only.

 

for (var i = 0; i < this.numFields; i++)

{

if (app.alert({nType:2,nIcon:2,cMsg:"This will lock the document for printing and email submission. Are you sure you want to continue?"})==4)

{

this.getField(getNthFieldName(i)).readonly=true;

}

else

{

}}

 

The pop up works, but the script hangs up at the pop up window and I have to Force Quit the app.  I can get the fields to set to read only without the pop up, however the folks using this form will need to understand the consquences. of selecting the "Done" button.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

37

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

Need javascript for button to set all fields to read only with pop up prompt

New Here ,
Mar 18, 2020

Copy link to clipboard

Copied

Hi, 

As a newbie, I'm stuck.  

This is as far as I could get in setting up a "Done" button to lock all the fields as read only.

 

for (var i = 0; i < this.numFields; i++)

{

if (app.alert({nType:2,nIcon:2,cMsg:"This will lock the document for printing and email submission. Are you sure you want to continue?"})==4)

{

this.getField(getNthFieldName(i)).readonly=true;

}

else

{

}}

 

The pop up works, but the script hangs up at the pop up window and I have to Force Quit the app.  I can get the fields to set to read only without the pop up, however the folks using this form will need to understand the consquences. of selecting the "Done" button.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

38

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
Mar 18, 2020 0
Adobe Community Professional ,
Mar 18, 2020

Copy link to clipboard

Copied

Move the if before the for.

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
Reply
Loading...
Mar 18, 2020 0
New Here ,
Mar 18, 2020

Copy link to clipboard

Copied

Thank you Bernd!   Sadly, as a newbie, simply moving the "if" before the "for" results in a snytax error I cannot resolve. 

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
Reply
Loading...
Mar 18, 2020 0
New Here ,
Mar 18, 2020

Copy link to clipboard

Copied

Considered your suggestion in a broader sense, then moved the script around a bit (logically) and bingo!

 

Thank you!

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
Reply
Loading...
Mar 18, 2020 0