6 Replies Latest reply on Feb 29, 2008 8:08 AM by (Scott_Hofmann)

    How Do You Change A Numeric Field To Blank When Zero?

    Jim MacD Level 1
      I'm using Adobe Acrobat 6.0 Professional, version 6.0.6.

      Can anyone help me with the code to change a numeric field to blank, when "0.00"?
        • 1. Re: How Do You Change A Numeric Field To Blank When Zero?
          gkaiseril MVP & Adobe Community Professional
          If you are using the "--- of" or simplified field name, you can put:

          if (event.value == 0) event.value = "";

          in the "Custom Validation" box of the "Validation" tab.

          If you are using the "Custom Calculation" script add it to the end of the scrpit.
          • 2. Re: How Do You Change A Numeric Field To Blank When Zero?
            I have a form field that adds three other input fields together and the result of which is enter into another field named "TFN"

            In the "TFN" Field --> "calculate" tab (simplified field notation)I have: (FeeN01 + FeeN02 + FeeN03)

            This leaves a "0" in the form field "TFN" on opening the form or upon using the form/clear form menu item in Acrobat.

            Based on Geo's post above I added to the simplified field notation so it now is: if (event.value == 0) event.value = ""; (FeeN01 + FeeN02 + FeeN03);

            That makes no zero appear but when data is inserted into FeeN01 no data appears in the "TFN" field even though I know it is taking it because I have another field that totals from "TFN" and it is calculating correctly.

            If anyone can point out what I'm doing incorrectly I'd appreciate it.

            - Scott
            • 3. Re: How Do You Change A Numeric Field To Blank When Zero?
              gkaiseril MVP & Adobe Community Professional
              Please carefully read the post. You can use any control statement inluding "if then" in a simplified field notation field.
              • 4. Re: How Do You Change A Numeric Field To Blank When Zero?
                Level 1
                Well I reread and reread the post. Even found a similar thread by you in another post but i'm still not seeing it. This is probably due to me not being much of a javascript programmer. I must be missing the syntax of an if/then statement. Here are the last two attempts with no success:

                var fa=this.getField("FeeN01");
                var fb=this.getField("FeeN02");
                var fc=this.getField("FeeN03");
                event.value = fa.value + fb.value + fc.value;
                if (event.value == 0) event.value = "";
                ------------
                var fa=this.getField("FeeN01");
                var fb=this.getField("FeeN02");
                var fc=this.getField("FeeN03");
                event.value = fa.value + fb.value + fc.value;
                if ((event.value == 0)) {
                event.value = ""
                } else {
                event.value = fa.value + fb.value + fc.value;
                }

                Am I even close?
                • 5. Re: How Do You Change A Numeric Field To Blank When Zero?
                  gkaiseril MVP & Adobe Community Professional
                  "no success" does not provide much to go on.

                  With your scripts, I get the concatenation of the sting values, so one has to force JavaScript to convert strings to numbers.

                  Make sure your field names are exact including case.

                  Make sure the calculation order is correct.

                  The following scripts all work:


                  var fa = 1 * this.getField("FeeN01").value;
                  var fb = 1 * this.getField("FeeN02").value;
                  var fc = 1 * this.getField("FeeN03").value;
                  event.value = fa + fb + fc;
                  if ((event.value == 0)) {
                  event.value = ""
                  }

                  // or

                  var fa = this.getField("FeeN01").value / 1;
                  var fb = this.getField("FeeN02").value / 1;
                  var fc = this.getField("FeeN03").value / 1;
                  event.value = fa + fb + fc;
                  if ((event.value == 0)) {
                  event.value = ""
                  }

                  // or
                  var fa = Number(this.getField("FeeN01").value);
                  var fb = Number(this.getField("FeeN02").value);
                  var fc = Number(this.getField("FeeN03").value);
                  event.value = fa + fb + fc;
                  if ((event.value == 0)) {
                  event.value = ""
                  }

                  The "sum of" also works with the "Custom validation script" of:

                  if (event.value == 0) event.value = "";
                  • 6. Re: How Do You Change A Numeric Field To Blank When Zero?
                    Level 1
                    Geo,

                    Thanks! Now that I understand where to place the code it's simple. The problem was that I was trying to insert

                    if (event.value == 0) event.value = "";

                    inside of the "simplified notation field" instead of in the "Custom Validation" box of the "Validation" tab. By placing it in the Validation box I finally got the results I was after. I'm stating this so someone else reading this post hopefully will get it sooner than I did. Becuase the clue to reread your initial post did not trigger an answer for me initially.

                    - Scott