# conditional threshold calculations

**dleflang**Hello,

I have 3 different types of calculations:

1) Add (x+ field value), also to display in form

2) Add numerical field value to another numerical field value, also display in form

3) Conditional threshold:

If A + B > 10, prepop field C with "High"

Or

If A + B < 10, prepop field C with "low"

are these possible?

I assume the souce code will need to be edited and uploaded?

Could you please suggst how the to go about the code?

Thank you

Dave

**fxr**hello Dave,

Yeah, you would need to upload source code again.

Get the form uploaded somewhere and I will have a go the javascript. I am just a little concerned about the reusability of the code, I assume your aim is use these types of calculations on a few different forms? I will try and streamline that process of reusing the code on multiple forms as much as possible.

--

I will summarise your desired calcs below

Field + number :-> Add Number

Field1 + Field 2 :-> Add fields

is field1 + field2 > of < Number (10) :-> added fields higher or lower than number

**dleflang**Reusability would be nice, but for now let’s just see if it can work:

https://dataramp.com/dataramp/form/20222332559?

Also, the first 2 summaries you have correctly.

The last one, you may have it right, I am not sure. Here is how I would state it:

Field1 + Field 2 :-> Add fields, if sum is greater than x, then show y in field 3. If sum is less than x, then show z in field 3.

Thank you

Dave

**fxr**OK, Dave I will have a go at that tomorrow.

I don't envisage too many problems.

Thanks for the clarification on the 3rd one, the aim of that summarising was to try and arrive at 'nicknames' for each calc so we quickly knew which one any of us was refering if we needed to talk about it. Also felt it would aid in any comments/variable names etc in any code that could be reused.

Anyway, you should see something back from me at some point tomorrow.

**dleflang**Thanks!

**fxr**OK, heres the script that will make those calcs work on that form:

Add that just before your closing </body> tag.

I have tried to make the code as reusable as possible; you just need to update the relevant variables names with any new element IDs for a particular field.

Test webpage/form is here

Let me know if you have any questions on that.