Highlighted

Help with my app alert

New Here ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try this:

 

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

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

Topics

How to, PDF forms

Views

60

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

Help with my app alert

New Here ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try this:

 

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

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

Topics

How to, PDF forms

Views

61

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
Participant ,
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);}

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

Copy link to clipboard

Copied

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

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...
Participant ,
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?

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...
New Here ,
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.  

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

Copy link to clipboard

Copied

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

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...
Most Valuable Participant ,
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();

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

Copy link to clipboard

Copied

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

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...
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

It's the logical operator AND.

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...
New Here ,
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?

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...
try67 LATEST
Most Valuable Participant ,
Sep 10, 2020

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;

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...
Resources
One Stop Solution for Acrobat
Edit a PDF