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

How to get a app.alert popup when 2 conditions are met in the fillable PDF?

New Here ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

Hello,

New here so I need some help.

 

How do I get a popup whenever the calculated field is less than 4 AND another field called  "super" has a number value greater than zero.

 

This is what I have and the "super" field doesn't seem to have any effect on the popup.

 

var s = this.getField("super").value;

if(event.value<4&&s>0);
app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")

 

TOPICS
How to , JavaScript , PDF forms

Views

1.3K

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 ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

remove the semicolon at the end of the if condition. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

Thanks, but the behavior didn't improve after I removed the semicolon. What I want is that there should be no popup unless the "super" field has a value AND the event field is less than 4.

 

What I have now:

var s = this.getField("super").value;

if(event.value<4&&s>0) app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")

 

Currently, the alert still pops up whenever the event field is less than zero regardless of what the "super" field value is. It's not taking into account the value of the "super" field. 

 

I'm not sure if it matters, but the event field is the sum of 4 checkboxes, each with an export value of 1. And the "super" field is what the user would put in,

 

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 ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

Where did you put script?

Check that event value is higher than zero otherwise if field is empty or 0 and 'super' higher than 0 it will still pop 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
New Here ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

The script is in validation. 

 

Sorry!! I misspoken.

Currently, the alert still pops up whenever the event field is less than 4 (not zero) regardless of what the "super" field value is. It's not taking into account the value of the "super" field. 

 

Thanks in advance for your help.

 

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 ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

I want to make it so that the pop alert would ONLY occur when the "super" has a value AND the event value is less than 4.

 

 

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 ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

O, I figured it out. I should have put the script with the 'super' rather than the previous event, which is labeled here as '4superReq'. Thanks for the effort in trying to help me figure it out. 

 

var s = this.getField("4superReq").value

if((event.value>0)&&(s<4)) app.alert("All 4 requirements must be met in order to qualify for the super rebate amount.")

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 ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

Just a couple of things to lookout for, if used as validation of "super" alert will only pop when the value of "super" is changed, and it won't pop when "4superReq" is changed, so if there is a possibility that "4superReq" value will be changed after "super" then use script as 'Calculate'.

If used as current, when you change "super" value an alert will pop even if "4superReq" is empty or 0.

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 ,
Jan 08, 2023 Jan 08, 2023

Copy link to clipboard

Copied

Your point is correct, but using the Calculate event for this is not a good idea, as the alert will show up each time you edit any field in the file (if the condition is true), unless you add additional conditions checking which field triggered the event. I would use the Validation event on both fields, instead.

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 ,
Jan 08, 2023 Jan 08, 2023

Copy link to clipboard

Copied

Thanks so much for the responses. I'm learning so much. Now I understand some of the past behavior. I am interested to know how I can add a condition to check which field triggered the event. Is it by adding the Validation event on both fields? Please advise. Thanks.

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 ,
Jan 08, 2023 Jan 08, 2023

Copy link to clipboard

Copied

LATEST

The place to look for this information is the Acrobat JavaScript Reference.

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#event-propertie...

 

See the "event.source" property.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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