0 Replies Latest reply: Feb 12, 2014 4:07 AM by Tonito99 RSS

    Issue calling onchange javascript function

    Tonito99

      Hello,

       

      I'm working on apex page (master detail page).

       

      The requirement is to calculate total amount from tabular form and set it to total field on master region.

      And then total field should be calculated with profit field from master region.

       

      I setup a javascript function which does calculation from tabular region and set total field on master region.

       

      Issue is that grand total of master region is not calculated, even for calculation of grand total I setup another function which is called onchange of tabular form total.

      onchange="CreditAmountTotal(), SellingPrice();"

       

      CreditAmountTotal()      -- Is working as expected

      SellingPrice()                -- Not doing calculation called from tabular region, it's working when is called from items on master region

       

      grand total = total + profit

       

      function CreditAmountTotal()

      {

        var items = document.getElementsByName("f07"); // Tabular form column to add up

       

        $total = 0;

        $itemValue = 0;

        for (var i = 0; i < items.length; i++)

        { 

         // if non-numeric character was entered, it will be considered as 0,

         // isNaN returns true if anything but number was entered

         if(isNaN(items[i].value) || items[i].value == null || items[i].value == "")

          $itemValue = 0;

         else

          $itemValue = parseFloat(items[i].value); // convert to number

        

         $total =$total+ $itemValue; // add up

        }

       

        // $x sets the text field to be updated to the column total just calculated

        $x('P20_AMOUNT').value = $total;

      }

       

        function SellingPrice(){

          function getVal(item){

         if(document.getElementById(item).value != "")

           return parseFloat(document.getElementById(item).value);

         else

           return 0;

          }

          document.getElementById('P20_SELLING_PRICE').value =

        getVal('P20_AMOUNT') + getVal('P20_TOTAL_PROFIT_AMOUNT') + getVal('P20_PARTICIPATION_AMOUNT');

        }

       

       

       

      Application Express 4.2.2.00.11

      Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

       

      Regards,

      Tonito