Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Need Help With Variable Field Calculation

$
0
0

I am putting together a form and would like to have the calculations worked out for the people using the form to minimize errors. The premise of the equation is ...

 

If suction pressure reads in PSIG, subtract from discharge to get total feet.

If suction pressure reads in Vacuum, add to the discharge pressure to get total feet.

 

My fields are set up as...

 

Discharge Pressure PSIG

Fixed           // fixed value of 2.31

Discharge Calc

 

Suction Pressure PSIG

Fixed 1        // fixed value of 2.31

V Suction Calc

 

Suction Vacuum

Fixed 2          // fixed value of 1.13

S Suction Calc

 

Total Feet

 

In the form, I have the following field equations set up:

 

Discharge Pressure PSIG x Fixed = Discharge Calc

Suction Pressure PSIG x Fixed 1 = V Suction Calc

Suction Vacuum x Fixed 2 = S Suction Calc

 

So, I have assigned each of the fields I need to work with a variable name

 

var v1 = Discharge Calc

var v2 = V Suction Calc

var v3 = S Suction Calc

var v4 = Suction PSIG

var v5 = Suction Vacuum

 

What I think should work logically would be the follow:

 

If v4 = 0, then v1+v3

if v5 = 0, then v1-v2

 

So, can you help me fix my script for the Total Feet field, please? I have no idea what I'm doing! This is what I have so far:

 

var v1 = getField("Discharge Calc").value;

var v2 = getField("V Suction Calc").value;

var v3 = getField("Suction Calc").value;

var v4 = getField("Suction PSIG").value;

var v5 = getField("Suction Vacuum").value;

 

if (v4=0)

     event.value = (v1+v3);

if (v=5)

     event.value = (v1-v2);

 

 

 

Many thanks for your help and have a nice day. 

 

 

 

 

 

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>