Skip navigation
Currently Being Moderated

Remove 0 Value in Calculated Field

Feb 9, 2009 12:51 PM

I copied the below question for another post here as it asks the question perfectly.

"I set up an invoice form to calculate totals from quantity x unit price. Every line has this formula, however the users may not have a priced item on every line of the form. My total column shows a $0.00 value until I input data. I'd rather have nothing show in that column unless quantity and price are entered. Is that possible?"

However, and I apologize, but I don't understand the answer that was posted. This is the first time I've needed a calculated field -- and I've not done scripting in Acrobat before.

Can someone walk me through the exact steps of how to enter and what to enter in the form to remove "0" values from the form?

Thanks, in advance, for any and all help.
 
Replies
  • Currently Being Moderated
    Feb 9, 2009 1:30 PM   in reply to (Diana_Pouppirt)
    What program did you use to create the forms?

    There are big differences in the code location and code language and syntax between Acrobat forms and LiveCycel Designer forms.

    You will have to test the to see if the result is zero and if it is zero you need to either make it an empty or null string.
     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Feb 9, 2009 2:55 PM   in reply to (Diana_Pouppirt)
    I believe you're referring to this thread: http://www.adobeforums.com/webx?128@@.59b5ca88

    If so, what part is not clear?

    George
     
    |
    Mark as:
  • DimitriM
    172 posts
    Dec 11, 2007
    Currently Being Moderated
    Feb 10, 2009 10:12 AM   in reply to (Diana_Pouppirt)
    Hi Diana,

    Since you are so new to Acrobat scripting, this post about how to find scripts and where scripts are located in PDF forms and documents-
    http://www.pdfpdfpdfpdf.com/2009/02/how-to-find-scripts-in-a-pdf/

    may be helpful for you. There is a link for a PDF download at the end of the post.

    Hope this helps,

    Dimitri
    WindJack Solutions
    www.windjack.com
    www.pdfscripting.com
     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Feb 10, 2009 10:39 AM   in reply to (Diana_Pouppirt)
    No need to apologize, it just wasn't clear to me what was wrong.

    If you've successfully added the document-level functions that were posted in the other topic, your next step is to set up the text field to call those functions. You would not use a custom calculation script, but rather a custom Format and Keystroke script.

    To do that, open up the Text Field properties window, select the Format tab, and select a format category of "Custom". You should then see where you can place a custom Format script and a custom Keystroke script.

    This is what you should use as the custom Format script:

    ds_format();

    And this is what you should use as the custom Keystroke script:

    ds_keystroke();

    These two functions are defined in the document-level JavaScript that you set up previously. Post again if this is not clear or doesn't work for you.

    George
     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Feb 10, 2009 12:20 PM   in reply to (Diana_Pouppirt)
    The problem may be the following line:

    > //Don't show anything if result is zero event.value="";}

    It should really be three lines:


    // Don't show anything if result is zero

    event.value="";

    }


    I can post a sample document if you can't get this to work.

    George
     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Feb 10, 2009 1:51 PM   in reply to (Diana_Pouppirt)
    No problem. Here is a sample PDF that demonstrates this:

    https://share.acrobat.com/adc/document.do?docid=9969aa7b-f43e-4a86-9d4 7-f77aaf5462c3

    George
     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Feb 11, 2009 10:26 AM   in reply to (Diana_Pouppirt)
    Sure you can. Have you tried it? But instead of a single space, you can have nothing by specifying an empty string. Just use quotes with nothing in between.

    You could also create a more general purpose set of functions such as:

    function ds_format(prefix_char) {

    if (+event.value) {
    // $ format for nonzero values
    AFNumber_Format(2, 0, 0, 0, prefix_char, true);
    } else {
    // Don't show anything if result is zero
    event.value = "";
    }
    }

    function ds_keystroke(prefix_char) {

    AFNumber_Keystroke(2, 0, 0, 0, prefix_char, true);

    }

    And call the functions by specifying the prefix character you want to use as a parameter. For example:

    ds_keystroke("$");

    or

    ds_keystroke("");

    George
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 5, 2012 10:10 PM   in reply to George Johnson

    I am having the same problem with having an unwanted 0 in the total line. I went through all the same steps but it didn't work. It looks like copying the script from the link that George posted is the solution but when I clicked on the link it came up as an error, I'm guessing it's just not there any more but I was wondering if I could get that sample PDF. Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 6, 2012 1:25 AM   in reply to Gressa

    Enter this code as the custom validation script of your field:

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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 12:41 PM   in reply to Gilad D (try67)

    Thanks for your help. I got the script to work, however since I had to input script, now I have an unwanted $ sign and decimal points. How do I incroporate in the script how to get rid of the $ sign as well as the decimal points? Please advise. Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 1:30 PM   in reply to Gressa

    You've probably set the formatting of the field to Number with the currency sybmol and decimal points...

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 1:51 PM   in reply to (Diana_Pouppirt)

    For just a plain numeric field with no currency symbol or special negative value display, I would use the following custom validation script:

     

    if(event.value == 0) {

    event.value = "";

    } else {

    event.value = event.value

    }

     

    For field formatted with a currency symbol of percentage, I would use a custom validation script with the JS function to dynamically format the field as a number or percentage.

     

    AFNumber_Format({nDec: 2, sepStyle: 0, negStyle: 0, currStyle: "", strCurrency: "", bCurrencyPrepend: false})

    AFPercent_Formatfunction AFPercent_Format({nDec: 2, sepStyle: 0, bPercentPrepend: false})

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)