12 月
5
2005

動態行數資料處理(PHP+JavaScript)

==== PHP ====

在Button的onClick裡面這樣寫

onClick=”CalDelayFee(‘{CalMoney}’,'{pay_date}’,document.all.real_date_{k}.value,'{FeeRate}’,’dely_mony_{k}’)”

==== Java Script ====

function CalDelayFee(CalMoney,pay_date,real_date,FeeRate,DelayMoneyField){

var RealDate = new Date(real_date.replace(“-“,”/”));

var PayDate = new Date(pay_date.replace(“-“,”/”));

var DateDiff = (RealDate – PayDate)/86400000;

var DelayMoney = parseFloat(CalMoney*DateDiff*FeeRate).toFixed(2);

document.getElementById(DelayMoneyField).value = DelayMoney;

}

** function(應繳金額,應繳日期,實繳日期,遲繳利率,傳入的動態資料ID){}

** toFixed(2) : 取小數點後兩位四捨五入

Related Posts

About the Author: 阿維

阿維雜記本的偷懶維護者

Comments are closed.