5 Replies Latest reply on Dec 3, 2012 8:02 AM by woodoochildx

    Need Help by some % calculation

    woodoochildx

      Hi Guys,

       

      i need some help calculating something.

      I have 5 boxes; "boxA" - "boxB" - "boxC" - "boxD" and "boxE". Box A–C are sums coming from other fields.

      "boxD" represent the VTA – and can be just 19% ore 0%.

      This means that "boxE" = ("boxA" + "boxB" + "boxC") * "boxD" ("box D" is equal with 0,19  – if the customer types 19% in the field – ore "0" (zero) – by leaving the "boxD" empty or typing the value "0" inside. A multiplication with 0 would be false, so it had to be ignored if the content of the "boxD" is 0)

       

      I suppose it will be something with "if" and "else" but how i say, I'm a greenhorn in this domain.

      Actually i found something that could help but i thing some parts – the definition of var v4, if v4 get the value 19% ore 0% – are missing.

       

      (function() {

       

       

         // Get the field values, as numbers

       

         var v1 = +getField("boxA").value;

       

         var v2 = +getField("boxB").value;

       

         var v3 = +getField("boxC").value;

       

         var v4 = +getField("boxD").value;

       

          // I suppose here comes some "if" "else" stuff for the definitoon of var4

       

         // Perform the calculation; the result is the content of the "boxE"

       

         var result = v4 * (v1 + v2 + v3);

       

       

         // Set the value of this field to the result

       

         event.value = result;

       

      })();