popAlert javascript?

Explorer ,
Feb 24, 2018

Copy link to clipboard

Copied

Hello everyone, I was wondering, is there a javascript that I could use to that would show and tell the user that they didn't click different button? And, if they have clicked the button it wouldn't show the alert. It's just kinda a reminder to click the other button. Can it be done? If so, can you share the script? Thanks.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try something like this:

if (this.calculate) app.alert("Please click the Halt button before proceeding.",3);

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

247

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

popAlert javascript?

Explorer ,
Feb 24, 2018

Copy link to clipboard

Copied

Hello everyone, I was wondering, is there a javascript that I could use to that would show and tell the user that they didn't click different button? And, if they have clicked the button it wouldn't show the alert. It's just kinda a reminder to click the other button. Can it be done? If so, can you share the script? Thanks.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try something like this:

if (this.calculate) app.alert("Please click the Halt button before proceeding.",3);

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

248

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
Feb 24, 2018 0
Most Valuable Participant ,
Feb 24, 2018

Copy link to clipboard

Copied

Sure, but what should trigger 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...
Feb 24, 2018 0
Explorer ,
Feb 24, 2018

Copy link to clipboard

Copied

well, there's a popMenu button with a bunch of choices. These choices show/hide other fields when chosen. The button I want to attach to the popAlert is to halt (or perform) the calculations. I just would like to remind the user to halt the calculations before the go any further and click the halt button. If they have clicked the halt button then the alert would not be needed and would not show. So, the trigger would be when the user would make a selection from the list of choices in the popMenu list. Would it help to see a bit of the popMenu script?

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...
Feb 24, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

Is the "halt button" an actual button, or something like a check-box?

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

Yes, it's a button (button name is Button2) and this is the script that's attached to it (MouseUp) -

   this.masterCalc = this.calculate = false;

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

That script doesn't make much sense. What are you trying to do there?

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

The script stops all the fields from calculating. It works to do that. Then I have a script to allow the calculations, but that's not a button. Its in the list of choices in the popMenu. Both seem to work fine.

I'm trying to have an alert pop out that would say, "Please click the Halt button before proceeding" and a OK button. But, if the Halt button is clicked the alert would not have to pop out.

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

Try something like this:

if (this.calculate) app.alert("Please click the Halt button before proceeding.",3);

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

Sorry I haven't replied sooner but I was busy doing something else, like sleeping. That is very interesting. How does this script work? I thought it would have a mention to the button, like "this.button2" (which is the Halt button name). How does it detect Button2 has or has not been clicked? How can I use this to also detect other buttons clicked or not?

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

It has nothing to do with the button, really. At least not directly. The button changes the calculate property to false, right? So if this property is true then we can assume the button hasn't been clicked, and therefore the message should be shown.

The issue is that buttons don't have states, so you can't test them in that way. You would need to either use them to change a (hidden) field or to set the value of a doc-level variable to see if they were clicked.

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

Thanks for explaining. You brought up another question for me. How would I stop the hidden fields from becoming visible as well? Kinda like not allowing the show/hide process to happen if the Halt button wasn't clicked. Or allowing all the hidden fields to become visible when the Halt button is clicked?

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

You would need to do it all in a script. You can't add a condition to other types of actions, like the "Show/hide field" command.

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

So, you're saying the show/hide command can be included, or not? In the popMenu, one of the items listed is to show approx. 30 hidden fields. Can your script halt that from happening if the Halt button has not been clicked? Or is that a different script?

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

No, it can't. You have to replace it with a JS command to show/hide the fields. Then you could do it under certain conditions.

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

could you show me what you're referring to? I don't have a clue as to how to accomplish it. Would that be very complicated?

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 25, 2018

Copy link to clipboard

Copied

No, it's actually quite simple. Here's how you hide a field using a script:

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

And how you show it:

this.getField("FieldName").display = display.visible;

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...
Feb 25, 2018 0
Explorer ,
Feb 25, 2018

Copy link to clipboard

Copied

Got it. But, how would I incorporate the two scripts? To also halt the show/hide and to alert the user to click the Halt button?

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...
Feb 25, 2018 0
Most Valuable Participant ,
Feb 26, 2018

Copy link to clipboard

Copied

if (this.calculate) {

     // insert code to show/hide the fields

}

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...
Feb 26, 2018 0
Explorer ,
Feb 26, 2018

Copy link to clipboard

Copied

Thanks for sending the latest script. I've tried it and found that it does just the opposite of what I was trying to do. If I don't click the Halt button then it does work, but it should be when I click the Halt button, that's when it should work. I've tried to play around with the script like this:

if (this.calculateNow) {

     // insert code to show/hide the fields

}

or,

if (this.calculate = false //and or true) {

     // insert code to show/hide the fields

}

I don't know what else to 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...
Feb 26, 2018 0
try67 LATEST
Most Valuable Participant ,
Feb 27, 2018

Copy link to clipboard

Copied

Replace the first line with:

if (this.calculate==false) {

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...
Feb 27, 2018 0