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.
Try something like this:
if (this.calculate) app.alert("Please click the Halt button before proceeding.",3);
Copy link to clipboard
Copied
Sure, but what should trigger it?
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?
Copy link to clipboard
Copied
Is the "halt button" an actual button, or something like a check-box?
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;
Copy link to clipboard
Copied
That script doesn't make much sense. What are you trying to do there?
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.
Copy link to clipboard
Copied
Try something like this:
if (this.calculate) app.alert("Please click the Halt button before proceeding.",3);
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?
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.
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?
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.
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?
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.
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?
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;
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?
Copy link to clipboard
Copied
if (this.calculate) {
// insert code to show/hide the fields
}
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.
Copy link to clipboard
Copied
Replace the first line with:
if (this.calculate==false) {