• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

another popAlert question

Participant ,
Mar 08, 2018 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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

511

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

Community Expert , Mar 09, 2018 Mar 09, 2018

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();

}

Votes

Translate

Translate
Community Expert ,
Mar 08, 2018 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.

Votes

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
Participant ,
Mar 08, 2018 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.

Votes

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 Expert ,
Mar 08, 2018 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();

Votes

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
Participant ,
Mar 08, 2018 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?

Votes

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 Expert ,
Mar 09, 2018 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;

Votes

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
Participant ,
Mar 09, 2018 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.

Votes

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

}

Votes

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

Copy link to clipboard

Copied

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

Votes

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 Expert ,
Mar 09, 2018 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();

}

Votes

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

Copy link to clipboard

Copied

got it! Thanks, buddy.

Votes

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
Participant ,
Mar 09, 2018 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?

Votes

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 Expert ,
Mar 09, 2018 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.

Votes

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
Participant ,
Mar 22, 2018 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.

Votes

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 Expert ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

LATEST

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.

Votes

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