Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Creating a Custom Pop-up Message?

Avatar

Level 3

I would like to create a custom pop-up message for a form.  What I'm looking for is when the user types in a series of numbers and if the total is under 650,000 a pop-up message will appear explaining what to do next and then the user clicks okay and the box disappears.  Thanks in advance for any help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

I'm not seeing the behaviour you're describing.

The way it's setup is the calculation only fires if all four fields have something in them (the script is on the calculate event). So you shouldn't be seeing a popup when you open the form. If you are setting a value of 0 in the field then that might trigger the popup but I just tried it and it seemed to work ok.

You will get a popup every time, after the fields are filled in, until the amount is over 650,000.

You could definitely put the script on a button instead of the calculate event - that might solve some of your problems.

View solution in original post

9 Replies

Avatar

Former Community Member

For the messageBox method see http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=001368.html

The attached contains the following logic on the calculate event on the field 'total'

// form1.page1.subform1.total::calculate - (JavaScript, client)

if (form1.page1.subform1.nf1.isNull || form1.page1.subform1.nf2.isNull || form1.page1.subform1.nf3.isNull || form1.page1.subform1.nf4.isNull) {

  this.rawValue = null;

}

else {

  var total_ = form1.page1.subform1.nf1.rawValue +

      form1.page1.subform1.nf2.rawValue +

      form1.page1.subform1.nf3.rawValue +

      form1.page1.subform1.nf4.rawValue;

  if (total_ < 650000) {

    xfa.host.messageBox("The total must be 650,000 or greater. Please review...","Total LT 650,000",1);

  }

  this.rawValue = total_;

}

The code assumes that fields n1 - nf4 are mandatory. If you need to do the validation prior to an action such as print or save, you will need additional logic to force the calculate to fire.

Steve

Avatar

Level 3

Okay I got this to work but I'm looking more for a pop-up message for the total if it is less than 650000 whether its 3 lines of input or 6 lines of input, because I have it set up where when the user selects a number from the drop down say like 3, three boxes appear to enter the numbers and then it totals up and the warning sign is for the under 650000.  The script you gave me wouldn't work on what I already had done but i got it to work else where on a new file.

Avatar

Level 3

This script seems to be what I'm looking for...not sure if its right but it semi works...

if (total > 650000) {

     this.rawValue=total;

} else {

     xfa.host.messageBox("Message Goes Here", "Title", 3, 1);

     }

this.rawValue=total;

The only thing is the message pops up when the form is opened and then every entry put in the pop up comes up until the total is over 650000.  What am I doing wrong or is there a way to show the total after all the entries have been placed?

Avatar

Level 10

Give this a try:

if ((nf1.rawValue != null) && (nf2.rawValue != null) && (nf3.rawValue != null) && (nf4.rawValue != null))
{
     var total = nf1.rawValue + nf2.rawValue + nf3.rawValue + nf4.rawValue;
     
     if (total < 650000)
     {
          xfa.host.messageBox("The total must be 650,000 or greater. Please review...","Total LT 650,000",1);
          this.rawValue = null;
     }
     else
     {
          this.rawValue = total;
     }
}

Avatar

Level 3

Okay this is good but I think now what I'm looking for is a situation like this.

The user totals up the numbers and if the total is below $650,000 a pop-up comes up saying that your total is under $$$ please get approval from your financial officer, other than that nothing happens to the total.  The pop-up message is used to notify the user what the right approval chain would be if the total value is under $650,000.  What changes would I need to make to the script in order for this to happen.  So far the answers have been very helpful and I'm almost there...   Thanks.

Avatar

Level 10

Not sure I'm following you...that's the behaviour of the script I posted. Or do you mean you want the total to be displayed even if it's under 650,000?

In which case this should do the trick:
if ((nf1.rawValue != null) && (nf2.rawValue != null) && (nf3.rawValue != null) && (nf4.rawValue != null))
{
     var total = nf1.rawValue + nf2.rawValue + nf3.rawValue + nf4.rawValue;
     
     if (total < 650000)
     {
          xfa.host.messageBox("The total must be 650,000 or greater. Please review...","Total LT 650,000",1);
     }
this.rawValue = total;
}

Avatar

Level 3

This is definitely closer to what I'm looking for.  The only problem is that the pop-up message come up when the file opens and every time an entry is made until the total adds more than $650,000.  Is there a way to possibly have the pop-up message come up once the total is completed.  Like I guess set up a button that can total the numbers up and then have the pop-up come up if the value is under $650,000 or maybe show the total after all the numbers have been entered?  Right now I have the total value set to $0.00 can I make that blank maybe?  Thanks.

Avatar

Correct answer by
Level 10

I'm not seeing the behaviour you're describing.

The way it's setup is the calculation only fires if all four fields have something in them (the script is on the calculate event). So you shouldn't be seeing a popup when you open the form. If you are setting a value of 0 in the field then that might trigger the popup but I just tried it and it seemed to work ok.

You will get a popup every time, after the fields are filled in, until the amount is over 650,000.

You could definitely put the script on a button instead of the calculate event - that might solve some of your problems.

Avatar

Level 3

Thanks it worked!!!  The values were set at 0 so I changed them and it works now.  Sorry for the confusion.