1 Reply Latest reply on Nov 21, 2012 8:34 AM by gamerg57

    calculate withholding using percentage and amount

    gamerg57

      i have a dynamic form with three decimal fields:

       

      grossamount (grossamount)

      withholding percentage (fwpercent)

      withholding amount (fwamount)

       

      i have the following scripts:

       

       

      form1.#subform[0].fwpercent::calculate - (FormCalc, client)

      fwamount/grossamount*100

       

       

      form1.#subform[0].fwamount::calculate - (FormCalc, client)

      grossamount*fwpercent/100

       

      I want to be able to change either the amount and/or the percent and have it calculate the other as shown in the scripts. If I open the form and plug in 100 for gross amount, then 10 for percent, the script works correctly and 10 is then shown in w/h amount. If I then go to the fw amount field and change it to 20, the percentage field still shows 10. the results are the same if I do amount first, it will then change the percentage value but won't update amount if I then update percentage. It only will work for whatever I do first. Can I get the fields to always be dependent on eachother every time one of them is changed?

        • 1. Re: calculate withholding using percentage and amount
          gamerg57 Level 1

          changed to the scripts below and it works as expected:

           

           

          form1.PaymentInfo.FederalWithholdingPercentage::exit - (JavaScript, client)

          FederalWithholding.rawValue=GrossAmount.rawValue*FederalWithholdingPercentage.rawValue/100;

           

           

          form1.PaymentInfo.FederalWithholding::exit - (JavaScript, client)

          FederalWithholdingPercentage.rawValue=FederalWithholding.rawValue/GrossAmount.rawValue*100;