AmrAbdeen
7/11/2015 - 10:12 AM

https://community.oracle.com/thread/3764388 Assuming the tabular form has following columns: f06 - Qty f07 - Price f10 - Total NOTE :

https://community.oracle.com/thread/3764388

Assuming the tabular form has following columns: f06 - Qty f07 - Price f10 - Total

 NOTE : Check your tabular form for the respective columns and accordingly change the below code.
 You can do it in two ways:
 Solution 1 : Using JavaScript

Edit your Page Attributes -> "JavaScript" section -> "Function and Global Variable Declarations" add the following:

//Checks whether the given string is numeric
function isNumeric(str) {
  if (!str.length || !isNaN(str.replace(/\s/,"z")/1)) {return true;}
  return false;
}

//Checks whether a field is null or numeric else returns 0
function f_chkNumberFlds(pVal) {
  var lVal;
  if ( pVal.length > 0 ) {
    if (isNumeric(pVal)) {
      lVal = pVal;
    } else {
      lVal = 0;
    }
  } else {
    lVal = 0;
  }
  return lVal;
}

//Calculates the row total
function f_calculate_total(pThis) {
  var total = 0;
  var row_id  = pThis.id.substr(4);
  var qty = f_chkNumberFlds($('#f06_'+row_id).val());
  var price = f_chkNumberFlds($('#f07_'+row_id).val());
  if (qty > 0 && price > 0) {
    total = parseFloat(qty*price);
  }
  $('#f10_'+row_id).val(total);
}

// Edit the columns Qty and Price. Go to Column Attributes -> "Element Attributes" add the following:
onchange="f_calculate_total(this);"