7 Replies Latest reply on Mar 5, 2012 9:15 AM by discodv
      • 1. Re: Display Positive Symbol
        $Nith$ Level 4

        I don't think this is possible through Patterns. However, you can change it through scripting.

         

        Note that you can't do it on a Numeric Field. It should be a Text Field instead.

         

        nith

        • 2. Re: Display Positive Symbol
          radzmar Adobe Community Professional & MVP

          You can use a script in the change event to switch between display patterns.

          this.format.picture = parseFloat(xfa.event.fullText) > 0 ? "num{'+'zzzzzzzzzzzz9}" : "num{zzzzzzzzzzzz9}";

          • 3. Re: Display Positive Symbol
            discodv Level 1

            This didn't work for me. I tried switching it to a text field and it still didn't work. I'm wondering if it has anything to do with the values being calculated instead of user inputting data. Oh well. Not a huge deal, just curious.

            • 4. Re: Display Positive Symbol
              radzmar Adobe Community Professional & MVP

              Sorry, missed the fact it's calculated.

               

              Try this in the calculate event.

              // Put your calculation script here!

              ...

              // Change the pattern depending on the result.

              this.format.picture = this.rawValue > 0 ? "num{'+'zzzzzzzzzzzz9}" : "num{zzzzzzzzzzzz9}";

               

              • 5. Re: Display Positive Symbol
                discodv Level 1

                Yes. It does the plus and I added the minus sign but it doesn't show the calculate value!! Just shows zero with a minus or positive symbol depending on value.

                • 6. Re: Display Positive Symbol
                  radzmar Adobe Community Professional & MVP

                  Ok,

                   

                  try it this way:

                  // Put your calculation script here!

                  this.rawValue = NumField1.rawValue * NumField1.rawValue;

                  // Change the pattern depending on the result.

                  this.format.picture = this.formattedValue > 0 ? "num{'+'zzzzzzzzzzzz9}" : "num{zzzzzzzzzzzz9}";

                  1 person found this helpful
                  • 7. Re: Display Positive Symbol
                    discodv Level 1

                    Ok. After playing around for a bit I figured it out. I ended up with this script. It will change the numerical field background color based on a positive, negative or neutral value and it will also display the positive/negative sign. With your help radzmar I was able to finish this. Thanks.

                     

                    var num1 = (xfa.resolveNode("form1.#subform.CurrentWeight[9]").rawValue) - (xfa.resolveNode("form1.#subform.PrevWeight[9]").rawValue)

                     

                    if (num1 > 0)

                    {

                    this.fillColor = "252,194,194";

                    this.format.picture = "num{'+'zz9.zz} 'lbs.'";

                    }

                    else if (num1 < 0)

                    {

                    this.fillColor = "194,252,194";

                    this.format.picture = "num{zz9.zz} 'lbs.'";

                    }

                    else if (num1 == 0)

                    {

                    this.fillColor = "194,194,252";

                    }

                    this.rawValue = num1;