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

Help with my app alert

New Here ,
Sep 10, 2020 Sep 10, 2020

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!

TOPICS
How to , PDF forms

Views

659

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 , Sep 10, 2020 Sep 10, 2020

Try this:

 

if (event.target.value == "no" && app.alert("my message",2,2)==4)

this.getField("my text").setFocus();

Votes

Translate

Translate
Community Expert ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Hi, see if this works for you:

if(event.target.value != "Off"){
app.alert("my message",2,2);}

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
New Here ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

That doesn't tell the script what to do when the user selects Yes/No.  

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 ,
Sep 10, 2020 Sep 10, 2020

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?

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
New Here ,
Sep 10, 2020 Sep 10, 2020

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.  

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
New Here ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Thanks for your time NesaNurani!  Try67 got it figured out for me!

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

Try this:

 

if (event.target.value == "no" && app.alert("my message",2,2)==4)

this.getField("my text").setFocus();

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
New Here ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

That worked like a charm.  May I ask what the && does?

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

It's the logical operator AND.

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
New Here ,
Sep 10, 2020 Sep 10, 2020

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?

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 ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

LATEST

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;

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