10 Replies Latest reply on Nov 16, 2012 8:30 AM by BarrierTech

# Custom Calculation Help!!!

Good Afternoon All,

I am having problems with writing a custom calculation script. I have got it close but I am missing something.

I need the calculation to take the total of the fields and if it doesn't add up to 100 then it rounds up to 100 if it over over 100 then it displays the actual value. Then it needs to be multipled by 4.5 then times 6.

Here is what I have so far

event.value=(this.getField("L BUMP").value + this.getField("FACE").value + this.getField("R BUMP").value) * this.getField("HEIGHT").value /144 >100?" ":"100"; * 4.5 * 6

Thank you!

• ###### 1. Re: Custom Calculation Help!!!

You're trying to cram too many things into one line. Use this instead:

var v = ((+this.getField("L BUMP").value) + (+this.getField("FACE").value) + (+this.getField("R BUMP").value)) * (+this.getField("HEIGHT").value / 144);

if (v>100) v = 100;

v *= 4.5 * 6;

event.value = v;

• ###### 2. Re: Custom Calculation Help!!!

Thanks try67!!

I made a error in the script I need to add the fields ("L BUMP)+("FACE")+("R BUMP") and then divide it by 12. I have tried to edit your script which worked perfect.

• ###### 3. Re: Custom Calculation Help!!!

It didn't work when I tried to do this.

var v = ((+this.getField("L BUMP").value) + (+this.getField("FACE").value) + (+this.getField("R BUMP").value)) / (12);

if (v>100) v = 100;

v *= 4.5 * 6;

event.value = v;

• ###### 4. Re: Custom Calculation Help!!!

So does it work now, or not?

• ###### 5. Re: Custom Calculation Help!!!

No it does. But I gave you the wrong information.

I need the calculation to work like this

("L BUMP)+("FACE")+("R BUMP") and then divide it by 12

if it doesn't equal 100 then it needs to round up if it is over then it needs to use the over 100 value then be multipled by 4.5 then times 6

Thank you so much for the help!!!

• ###### 6. Re: Custom Calculation Help!!!

Try being a bit more specific... Is there an error message in the JS

console? Does it give the wrong answer?

• ###### 7. Re: Custom Calculation Help!!!

So basically you need to change this:

if (v>100) v = 100;

To this:

if (v<100) v = 100;

• ###### 8. Re: Custom Calculation Help!!!

I changed what you said and there were no errors but the field displays a zero value.

Here is the script as it stands

var v = ((+this.getField("L BUMP").value) + (+this.getField("FACE").value) + (+this.getField("R BUMP").value)) / (12);

if (v<100) v = 100;

v *= 4.5 * 6;

event.value = v;

• ###### 9. Re: Custom Calculation Help!!!

It's hard to say what's going wrong without seeing the file. Can you share

it somewhere?

You can also send it to me personally at try6767 [at] gmail.com

• ###### 10. Re: Custom Calculation Help!!!

I just shot the form over to you.