Skip to main content
Participating Frequently
March 18, 2020
Question

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

  • March 18, 2020
  • 1 reply
  • 548 views

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.

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
March 18, 2020

Move the if before the for.

Participating Frequently
March 18, 2020

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

Participating Frequently
March 18, 2020

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

 

Thank you!