Copy link to clipboard
Copied
I have an alert in document-level that opens if a certain button is not hidden and then when that button is hidden, the alert doesn't open. So that works fine but when I tried adding a second alert, I get issues. What I'm trying to accomplish is there are two parts to a pdf form (PART I and PART II). If part 1 doesn't have a button hidden, then an alert will pop up when the document is opened. After part 1 has been digitally signed, the button will hide and that alert won't popup anymore but a second alert will pop up if part 1's button hidden AND part 2's button is not hidden. Once part 2 has been signed, part 2's button is hidden and no more alerts should pop up.
It all works up to the last part. The second alert still pops up even though both buttons are hidden. Here's my code:
var VerifyPartI = this.getField("Verify PART I");
var VerifyPartII = this.getField("Verify PART II");
if (VerifyPartI.hidden == false){
if(app.alert("Inputted text",2,1,"Title of window")!=1) this.closeDoc(true);
} else {
if (VerifyPartII.hidden == false && VerifyPartI.hidden == true);{
app.alert("Inputted text",3,0,"Title of window");
}
}
I don't know how to close this if/then statement.
Copy link to clipboard
Copied
The issue is with how the second "if" is constructed.
Get rid of the semi-colon, its ending the if before the block containing the alert.
However, in general you have some badly formed code. The second "if" should be an "else if", and include better formatting
There is no reason to compare something to true or false, since these values are already true or false.
Copy link to clipboard
Copied
Thom,
I'm using that second if to state that if they click the cancel button, the document closes.
Copy link to clipboard
Copied
Thom and George,
The removal of that semicolon fixed the issue along with the change of George's suggestion. Thanks ya'll!
Copy link to clipboard
Copied
It seems like this is what you're after:
if (VerifyPartI.hidden == false) {
if (app.alert("Inputted text", 2, 1, "Title of window") != 1) {
this.closeDoc(true);
}
} else {
if (VerifyPartII.hidden == false) {
app.alert("Inputted text", 3, 0, "Title of window");
}
}
Though it could be simplified a bit. Note that the "hidden" field property has been deprecated in favor of the "display" field property, which can have four possible values.
Copy link to clipboard
Copied
George,
I tried that and it does the same thing as the original script. After both buttons are hidden, the second alert still comes up when the doc is open. Once both buttons are hidden, the form doesn't need anymore alerts to popup.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now