sAVE bUTTON pROBLEM
Posted: Tue Dec 06, 2011 11:36 am
Dear all,
I am having a strange problem with the save button on one of my forms. The save button seems unable to execute when i add the following JavaScript below in the form JavaScript section . Have been unable to find the bug or how to know which line is causing conflict!!
function nuLoadThis() {
calcinv_total();
}
function nuBeforeSave(){
if ( !validateCloseDate() )
return false;
calcinv_total();
return true;
}
function calclinetotal(pthis) {
if (pthis.length == 18) {
// Paramter passed through from tri_product_id
PRE = pthis;
} else {
// Paramter passed through from tri_units or tri_cost
PRE = pthis.name.substring(0,18);
}
//calculate the total of the line by quantity * cost
var unitCost = Number(document.getElementById(PRE+'tri_unit_cost').value);
var total = Number(document.getElementById(PRE+'tri_total').value);
var price = Number(document.getElementById(PRE+'tri_amount').value);
//atish discount part
var discount = Number(document.getElementById(PRE+'tri_discount').value);
discount = (100 - discount)/100;
price = unitCost * discount;
total = price ;
document.getElementById(PRE+'tri_amount').value = price;
document.getElementById(PRE+'tri_total').value = total;
//if the values of the total field is blank then fill them in
if(document.getElementById(PRE+'tri_total').value < '0'){
document.getElementById(PRE+'tri_amount').value = price;
document.getElementById(PRE+'tri_total').value = total;
}
nuFormat(document.getElementById(PRE+'tri_unit_cost'));
nuFormat(document.getElementById(PRE+'tri_total'));
calcinv_total();
}
function calcinv_total() {
//calculate the entire total of all the line totals
var invAmount = Number(0);
var subformToPopulate = 'FMInvoiceItems';
var fieldToPopulate = 'tri_total';
var theList = nuSubformRowArray(subformToPopulate);
for (var i = 0 ; i < theList.length ; i++){
strlength = '0000'+ i;
pstrlength = strlength.length;
PRE = 'FMInvoiceItems' + ('0000'+ i).substring(pstrlength-4);
if (document.getElementById("row"+PRE).checked != 'true') {
var fieldInRow = document.getElementById(theList + fieldToPopulate);
invAmount = invAmount + Number(fieldInRow.value) ;
}else {
invAmount = 0;
}
}//for loop
document.getElementById('tra_amount').value = invAmount;
}//inv total
function getRowPrefixFromLookup(pthis) {
// Needed to update row price totals if user changes a product lookup
PRE = pthis.name.substring(4,22);
nuCreateCookie('row_name_for_transaction_item', PRE, 0);
calclinetotal(nuReadCookie('row_name_for_transaction_item'));
}
I am having a strange problem with the save button on one of my forms. The save button seems unable to execute when i add the following JavaScript below in the form JavaScript section . Have been unable to find the bug or how to know which line is causing conflict!!
function nuLoadThis() {
calcinv_total();
}
function nuBeforeSave(){
if ( !validateCloseDate() )
return false;
calcinv_total();
return true;
}
function calclinetotal(pthis) {
if (pthis.length == 18) {
// Paramter passed through from tri_product_id
PRE = pthis;
} else {
// Paramter passed through from tri_units or tri_cost
PRE = pthis.name.substring(0,18);
}
//calculate the total of the line by quantity * cost
var unitCost = Number(document.getElementById(PRE+'tri_unit_cost').value);
var total = Number(document.getElementById(PRE+'tri_total').value);
var price = Number(document.getElementById(PRE+'tri_amount').value);
//atish discount part
var discount = Number(document.getElementById(PRE+'tri_discount').value);
discount = (100 - discount)/100;
price = unitCost * discount;
total = price ;
document.getElementById(PRE+'tri_amount').value = price;
document.getElementById(PRE+'tri_total').value = total;
//if the values of the total field is blank then fill them in
if(document.getElementById(PRE+'tri_total').value < '0'){
document.getElementById(PRE+'tri_amount').value = price;
document.getElementById(PRE+'tri_total').value = total;
}
nuFormat(document.getElementById(PRE+'tri_unit_cost'));
nuFormat(document.getElementById(PRE+'tri_total'));
calcinv_total();
}
function calcinv_total() {
//calculate the entire total of all the line totals
var invAmount = Number(0);
var subformToPopulate = 'FMInvoiceItems';
var fieldToPopulate = 'tri_total';
var theList = nuSubformRowArray(subformToPopulate);
for (var i = 0 ; i < theList.length ; i++){
strlength = '0000'+ i;
pstrlength = strlength.length;
PRE = 'FMInvoiceItems' + ('0000'+ i).substring(pstrlength-4);
if (document.getElementById("row"+PRE).checked != 'true') {
var fieldInRow = document.getElementById(theList + fieldToPopulate);
invAmount = invAmount + Number(fieldInRow.value) ;
}else {
invAmount = 0;
}
}//for loop
document.getElementById('tra_amount').value = invAmount;
}//inv total
function getRowPrefixFromLookup(pthis) {
// Needed to update row price totals if user changes a product lookup
PRE = pthis.name.substring(4,22);
nuCreateCookie('row_name_for_transaction_item', PRE, 0);
calclinetotal(nuReadCookie('row_name_for_transaction_item'));
}