3 Replies Latest reply on Jun 23, 2014 3:56 PM by gkaiseril

Formulas for If Statement

I am building a pdf form with Adobe and need help with using the custom calculation feature of the form builder.  I have never programmed in Java before so if someone can help with converting these formulas to Java Script that would be great.

Here are the formulas that I need help with:

=IF(\$H\$8=0," ",\$H\$8-13)

=IF(SUM(C22:C28)=0," ",SUM(C22:C28))

=IF(SUM(C29,C42)=0," ",SUM(C29,C42))

=IF((OR(E16="",D16="")),0,IF((E16<D16),((E16-D16)*24)+24,(E16-D16)*24)+IF((OR(H16="",G16=" ")),0,IF((H16<G16),((H16-G16)*24)+24,(H16-G16)*24))+IF((OR(K16="",J16="")),0,IF((K16<J16), ((K16-J16)*24)+24,(K16-J16)*24))+IF((OR(N16="",M16="")),0,IF((N16<M16),((N16-M16)*24)+24,( N16-M16)*24))+IF((OR(Q16="",P16="")),0,IF((Q16<P16),((Q16-P16)*24)+24,(Q16-P16)*24))+IF((O R(T16="",S16="")),0,IF((T16<S16),((T16-S16)*24)+24,(T16-S16)*24)))

I did everything in excel now i need to move these functions to Adobe. Also is there a way to import lines of data in a drop down box rather than entering one line at a time??

Thank you so much for your help.

Cheers

• 2. Re: Formulas for If Statement

excel:  IF(condition, result if true, result if false)

Well in JS, it's kind of the same thing:

if(condition){

result if true

}

else{

result if false

}

Just like in excel, you can nest them.  You can also add more than one condition like that:

if((condition1) && (condition2)){  //where "if" will be true if both conditions are met

or like that:

if((condition1) || (condition2)){  //where || means "or" so "if" will be true if one of the two conditions is met

Sometimes, many situations might need different results:

if(condition1){

result if true

}

else if(condition2){

result if true

}

else{

condition if they're all false

}

• 3. Re: Formulas for If Statement

Also there is more than one equality operator for JavaScript and it is the set operator, "=".