Skip navigation
Currently Being Moderated

Using formCalc or JavaScript

Dec 19, 2011 4:56 AM

Good Day All;

I am now getting into forms that require some calculations. In doing some reading I have seen where both JavaScript and FormCalc are being used. Can anyone tell me which is the better to use?

For the form I am currently designing I have tried formCalc but I have hit a wee bump. I have ued the following “if(cost_p_h ne 0) thenSum(60/file_p_h) endif” and received the following error

Script failed (language is formcalc; context is xfa[0].form[0].form1[0].#subform[0].#subform[1].Table1[0].Row1[0].dur [0])

script=if(cost_p_h ne 0) thenSum(60/file_p_h) endif

   Error: syntax error near token 'thenSum' on line 1, column 25.

I am currently running Acrobat Pro 8 and the version of LiveCycle Designer is 8.05

Thanks All.

Chomp

 
Replies
  • Currently Being Moderated
    Dec 19, 2011 5:40 AM   in reply to The Chomp

    Hello Chomp,

     

    In your script you should give a space between then and Sum as follows:

     

    if(cost_p_h ne 0) then Sum(60/file_p_h) endif”

     

    Hope,this will help you.

     

    Thanks,

    Debadas.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 19, 2011 6:32 AM   in reply to The Chomp

    Hello Chomp,

     

    You can not divide by zero, so you need to add code to only allow the division when you have a non-zero divisor.

     

    So for  this script Sum(60/file_p_h), you have check wheather file_p_h is non-zero.


    if(file_p_h ne 0) then Sum(60/file_p_h) endif

     

    Thanks,

    Debadas.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 20, 2011 7:48 PM   in reply to The Chomp

    It is becuase if files in blank it counts that as not equal to 0 so does the calculation. try:

     

    if (files > 0) then

         Sum(60/files)

    else $ = ""

    endif

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points