2 Replies Latest reply on Apr 23, 2017 3:35 AM by mirza5313

    Multiply numeric fields by user entered input

    mirza5313 Level 1

      Hello I am wondering if any one help me.. I have very simple calculation but got stuck I have more then 59 numeric fields that i wan to multiply by user entered data!!

       

      Capture.PNG

       

      I just want when any one enter at QUANTITY field 2 or whatever they want the last Grand total field will show 160 as the text1 price is 80.00 $, so far I have this js code but this code is work only one field.

       

      // Get first field value, as a number

       

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

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

       

      // Calculate and set this field's value to the result

       

      event.value = 80 * (v2);

      event.value = 80 * (v3);

       

       

      So I want there will be text1 to text 59 in same condition

       

      event.value = 80 * (v2);

       

      will be change according to item price...

        • 1. Re: Multiply numeric fields by user entered input
          JR_Boulay Adobe Community Professional

          Hi.

           

          Assuming that your fields uses the Field naming convention and are named as:

           

          price.0, price.1, price.2, etc.

          and

          quantity.0, quantity.1, quantity.2, etc.

          and

          total.0, total.1, total.2, etc.

          (Or whatever name you want for "total", here the number is the only thing that matters)

           

           

          Place this script as a calculation script in all "total.n" fields:

           

          oNomChamp = this.event.target.name;
          var nNumRangee = oNomChamp.substring(oNomChamp.lastIndexOf('.')+1);
          nPrice = this.getField("price." + nNumRangee).value;
          nQuantity = this.getField("quantity." + nNumRangee).value;
          event.target.value = (nPrice * nQuantity) * 1;
          

           

           

          Using the Field naming convention is easier and automatic when duplicating fields via: right-clic (upon a field) : Create multiples copies…

          • 2. Re: Multiply numeric fields by user entered input
            mirza5313 Level 1