another popAlert question

Explorer ,
Mar 08, 2018

Copy link to clipboard

Copied

I'm using this script to alert the user to click a button:

if (this.calculate) app.alert("Please click the ''On'' button before proceeding.\n\n**Note:\nThis alert will appear whenever the ''On'' button is not clicked\n\nBe sure to click the ''Off'' button when you are ready to perform your calculations.\n",3);

What I'd like to know is, is it possible to use the OK button in the alert to set (click the Button2) when the OK is clicked to close the popAlert window. I have two buttons that hide and show when clicked. Button2 is visible and when I click it, it hides and shows Button4. It's just to turn on then turn off. So, would it possible to use the OK button to click Button2, hide it, and show Button4? Then they can click Button4 for themselves when they are ready to. It would help streamline that process of turning the buttons on/off for the user.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

If you want to do the same thing from two locations, yes.

Then you can do something like this:

if (app.alert("Hello!",3,1)==1) {

     mouseUpA();

}

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

186

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

another popAlert question

Explorer ,
Mar 08, 2018

Copy link to clipboard

Copied

I'm using this script to alert the user to click a button:

if (this.calculate) app.alert("Please click the ''On'' button before proceeding.\n\n**Note:\nThis alert will appear whenever the ''On'' button is not clicked\n\nBe sure to click the ''Off'' button when you are ready to perform your calculations.\n",3);

What I'd like to know is, is it possible to use the OK button in the alert to set (click the Button2) when the OK is clicked to close the popAlert window. I have two buttons that hide and show when clicked. Button2 is visible and when I click it, it hides and shows Button4. It's just to turn on then turn off. So, would it possible to use the OK button to click Button2, hide it, and show Button4? Then they can click Button4 for themselves when they are ready to. It would help streamline that process of turning the buttons on/off for the user.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

If you want to do the same thing from two locations, yes.

Then you can do something like this:

if (app.alert("Hello!",3,1)==1) {

     mouseUpA();

}

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

187

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 08, 2018 0
Most Valuable Participant ,
Mar 08, 2018

Copy link to clipboard

Copied

No, you can't emulate clicking a button with a script. What you can do, though, is have that button call a function that does all the things that should happen when it is clicked, and then call that same function from your other code.

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 08, 2018 0
Explorer ,
Mar 08, 2018

Copy link to clipboard

Copied

Thanks for responding. The only thing is, is I wouldn't know how to do what you're saying. Would you be able to show me with a little example? If it's not too much trouble. I'd really like to see how it would be done. Thanks, try.

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 08, 2018 0
Most Valuable Participant ,
Mar 08, 2018

Copy link to clipboard

Copied

Create a doc-level script:

function mouseUpA() {
     app.alert("Hello!");
}

As the MouseUp event of field A enter:

mouseUpA();

Then as the MouseUp event of another field you can use:

if (this.calculate) mouseUpA();

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 08, 2018 0
Explorer ,
Mar 08, 2018

Copy link to clipboard

Copied

Hi Try, thanks for the script. I've been playing around with it and got it to work. I mean the function and the popAlert but the On/Off (Button2) button is not triggered and remained uneffected.

I was hoping to have Button2 hide and the calculate (this.masterCalc = this.calculate = false;) to trigger when the "OK" in the popAlert is clicked to close the alert window. You helped me with the script last week. And the script was right on with popping out the alert when the other button is not clicked. I thought you were saying that it could be done from the popAlert window "OK". Am I missing something? Not doing it correctly?

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 08, 2018 0
Most Valuable Participant ,
Mar 09, 2018

Copy link to clipboard

Copied

Sorry, I've lost you there... So you just want to hide the button? That's easily done:

this.getField("Button2").display = display.hidden;

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 09, 2018 0
Explorer ,
Mar 09, 2018

Copy link to clipboard

Copied

I'm referring to the OK button in the popAlert window. To have that button close the alert wind and be the trigger that when clicked to make Button2 hide and to run this script (this.masterCalc = this.calculate = false;). Instead of having to manually click Button2 after I click the alert window OK button to close it. Originally, you helped me with this see link below.

popAlert javascript?

What I'd like to do now is to have the OK button in the popAlert window be the trigger. Click that button and it would close the alert window and also halt the calculations and hide Button2. That's what I'm to do if it's possible.

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 09, 2018 0
Most Valuable Participant ,
Mar 09, 2018

Copy link to clipboard

Copied

Just add the other commands after the alert window... If you want to make sure the user clicked on OK check the return value of the method. It will return "1" if "OK" was clicked. Of course, if that's the only option then it can't be anything else.

For example:

if (app.alert("Hello!",3,1)==1) {

     // do some other stuff

}

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 09, 2018 0
Explorer ,
Mar 09, 2018

Copy link to clipboard

Copied

Would the scripts in your second reply above still be needed?

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 09, 2018 0
Most Valuable Participant ,
Mar 09, 2018

Copy link to clipboard

Copied

If you want to do the same thing from two locations, yes.

Then you can do something like this:

if (app.alert("Hello!",3,1)==1) {

     mouseUpA();

}

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 09, 2018 0
Explorer ,
Mar 09, 2018

Copy link to clipboard

Copied

got it! Thanks, buddy.

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 09, 2018 0
Explorer ,
Mar 09, 2018

Copy link to clipboard

Copied

So, I was playing around with the script and every once in a while I figure something out. But, it's by pure luck. I kept looking at your example and what I have tried to do is enclose the other stuff to do in curly brackets and I'll be a sun of gun it worked to do what I wanted. I placed this script in the mouseEnter action. When Button 2 was not clicked, the popAlert window would pop open. Then when I clicked the OK button in the alert window, it closed the alert and performed the other stuff. But, I couldn't have come up with it if it weren't for you helping me. Thanks again for all your time.

if (this.calculate) app.alert("Please click the ''On'' button to achieve optimum performance before proceeding.\n\n**Note:\nThis alert will appear whenever the ''On'' button is not clicked when changing modes or when resetting.\n\nBe sure to click the ''Off'' button when you are ready to perform your calculations.\n",3); {

     this.getField("Button 2").display = display.hidden;

     this.getField("Button 4").display = display.visible;

     this.masterCalc = this.calculate = false;

}

What do you think? Did I do good? It this the right way to script the solution? Do you see any problems with 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
Reply
Loading...
Mar 09, 2018 0
Most Valuable Participant ,
Mar 09, 2018

Copy link to clipboard

Copied

Your code doesn't make sense. What's the condition here? Is it that calculate is true? If so, then the curly brackets need to start after it.

The way you have it set up now the last three lines of code will execute no matter what, as only the alert is associated with the if-statement.

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 09, 2018 0
Explorer ,
Mar 22, 2018

Copy link to clipboard

Copied

Hi Try67, I was wondering if you could do me a small favor and take a look at my latest posted question. Here's the link,

Need help with a script to calculate time, minutes and hours

It may sound confusing and not very clear but thats due to me being unclear and confused. Mainly because I'm just starting to work on the concept and as you know concepts start in the dark and develop from there. Anyways, hopefully, I can get some help, suggestions, and ideas from the members here.

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 22, 2018 0
try67 LATEST
Most Valuable Participant ,
Mar 22, 2018

Copy link to clipboard

Copied

I saw it but it was not clear to me what you're trying to achieve, so I didn't reply. If you want send me an email (try6767 at gmail.com) and we could discuss it privately in more detail.

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 22, 2018 0