Forum Stats

  • 3,851,371 Users
  • 2,263,968 Discussions


Issue calling onchange javascript function

Tonito99 Member Posts: 67 Blue Ribbon


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;


    $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);


     return 0;


    document.getElementById('P20_SELLING_PRICE').value =

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


Application Express

Oracle Database 11g Express Edition Release - Production



This discussion has been closed.