Last active
August 29, 2015 14:24
-
-
Save AmrAbdeen/1e51483ceed35c225eb2 to your computer and use it in GitHub Desktop.
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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);" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment