Copy link to clipboard
Copied
I have an app alert that is triggered by a check box being checked using a mouse up event. The standard javascript of:
if(4==app.alert(" my message",2,2))
this.getField("mytext").setFocus();
works fine, except when you go to unclick the checkbox, the app alert pops up again. So I transitioned it to:
if (event.target.value == "no")
app.alert("my message",2,2)
this.getField("my text").setFocus();
By the way, "no" is the actual export value. The issue is that when the app alert pops up, now the yes/no question doesn't opperate as intended. The user can click Yes or No and it still takes them to the field "my text." If the user selects no, I just want the pop up to close. If the user selects yes, then I want it to take them to "my text."
Help would be greatly appreciated!
Try this:
if (event.target.value == "no" && app.alert("my message",2,2)==4)
this.getField("my text").setFocus();
Copy link to clipboard
Copied
Hi, see if this works for you:
if(event.target.value != "Off"){
app.alert("my message",2,2);}
Copy link to clipboard
Copied
That doesn't tell the script what to do when the user selects Yes/No.
Copy link to clipboard
Copied
I helped you with app.alert, I assumed you will add rest of the code yourself.
If you need help then pls tell me what do you want it to do if it's Yes and no?
Copy link to clipboard
Copied
if (event.target.value == "no")
app.alert("my message",2,2)
this.getField("my text").setFocus();
By the way, "no" is the actual export value. The issue is that when the app alert pops up, now the yes/no question doesn't opperate as intended. The user can click Yes or No and it still takes them to the field "my text." If the user selects no, I just want the pop up to close. If the user selects yes, then I want it to take them to "my text."
This issue I am having is that when I add setFocus command, it doesn't just apply to the Yes button; it takes them to the "my text" field regardless of the user input.
I apologize if I am not being very clear, this is my first rodeo.
Copy link to clipboard
Copied
Thanks for your time NesaNurani! Try67 got it figured out for me!
Copy link to clipboard
Copied
Try this:
if (event.target.value == "no" && app.alert("my message",2,2)==4)
this.getField("my text").setFocus();
Copy link to clipboard
Copied
That worked like a charm. May I ask what the && does?
Copy link to clipboard
Copied
It's the logical operator AND.
Copy link to clipboard
Copied
If I could bother you for one more thing, is it possible to have some checkboxes become visible should the user select no to the above referenced app alert?
Copy link to clipboard
Copied
Yes:
if (event.target.value == "no") {
if (app.alert("my message",2,2)==4) {
this.getField("my text").setFocus();
} else {
this.getField("Checkbox1").display=display.visible;
}
}
However, this does not turn it back to hidden if something else is selected... So you might want to add this line somewhere (depending on how it should work):
this.getField("Checkbox1").display=display.hidden;