javascript-以oracle apex表格形式的动态计算:sys.htp.p
作者:互联网
我有表格形式,其中col1和col2是数字,而col3应该包含col1和col2之间的区别.
col1已经有数据并且col 1是可编辑的,基于col1的更改,col3数据将动态更改.
为了实现这一点,我使用了ajax回调过程和JavaScript,但是问题是当差异为0.xx -0.xx时,我得到了解析错误.
我能够在col3中打印的其他值.
Declare
p_curr number;
p_prev number;
p_diff number;
Begin
p_prev := to_number(apex_application.g_x01);
p_curr := to_number(apex_application.g_x02);
SELECT p_curr - p_prev into p_diff
from dual;
-- return calculated value
sys.htp.p(p_diff);
End;
–JavaScript
function f_CALC_DIFF(pThis) {
var row_id = pThis.id.substr(4);
var s = $('#f18_'+row_id).val().replace(/[^\d.-]/g, '');
var curr = $(pThis).val().replace(/[^\d.-]/g, '');
if(!s){
var s= 0;
var prev = s;}
else{
var prev = s;}
apex.server.process
( "CALC_DIFF", { x01: prev, x02: curr },
{ success: function( pData ) {
$('#f23_'+row_id).val(pData);}}
);
}
请为上述问题提出解决方案.
我正在使用Oracle Apex 4.2版
解决方法:
与其使用昂贵的AJAX调用数据库,不如使用JavaScript.
function f_CALC_DIFF(pThis) {
var row_id = pThis.id.substr(4);
var s = $('#f18_'+row_id).val().replace(/[^\d.-]/g, '');
var curr = $(pThis).val().replace(/[^\d.-]/g, '');
if(!s){
var s= 0;
var prev = s;}
else{
var prev = s;}
var diff = 0;
diff = (curr - prev);
var n = diff.toFixed(2);
alert (n);
$('#f23_'+row_id).val(n);
// Please remove the AJAX call to database.
/*apex.server.process
( "CALC_DIFF", { x01: prev, x02: curr },
{ success: function( pData ) {
$('#f23_'+row_id).val(pData);}}
);
} */
标签:oracle-apex,oracle,javascript,tabular-form 来源: https://codeday.me/bug/20191119/2034303.html