住房贷款、消费贷款计算器代码--拷贝下来就能用

类别:网站制作 点击:0 评论:0 推荐:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>贷款中心-计算器</TITLE>
<style>
BODY {
 FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
TD {
 FONT-SIZE: 12px; LINE-HEIGHT: 18px; FONT-STYLE: normal; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
A:link {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
A:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
A:active {
 FONT-WEIGHT: normal; COLOR: #0066cc; FONT-STYLE: normal; TEXT-DECORATION: none
}
A:hover {
 FONT-WEIGHT: normal; COLOR: #003399; FONT-STYLE: normal; TEXT-DECORATION: none
}
.gray-blue:link {
 FONT-WEIGHT: normal; COLOR: #444444; FONT-STYLE: normal; TEXT-DECORATION: none
}
.gray-blue:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #444444; FONT-STYLE: normal; TEXT-DECORATION: none
}
.gray-blue:active {
 FONT-WEIGHT: normal; COLOR: #336699; FONT-STYLE: normal; TEXT-DECORATION: none
}
.gray-blue:hover {
 FONT-WEIGHT: normal; COLOR: #336699; FONT-STYLE: normal; TEXT-DECORATION: none
}
.lblue-white:link {
 FONT-WEIGHT: normal; COLOR: #a5c4df; FONT-STYLE: normal; TEXT-DECORATION: none
}
.lblue-white:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #a5c4df; FONT-STYLE: normal; TEXT-DECORATION: none
}
.lblue-white:hover {
 FONT-WEIGHT: normal; COLOR: #ffffff; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-org:link {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-org:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-org:active {
 FONT-WEIGHT: normal; COLOR: #ff9900; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-org:hover {
 FONT-WEIGHT: normal; COLOR: #ff9900; FONT-STYLE: normal; TEXT-DECORATION: none
}
.org-black:link {
 FONT-WEIGHT: normal; COLOR: #ff9900; FONT-STYLE: normal; TEXT-DECORATION: underline
}
.org-black:visited {
 FONT-WEIGHT: normal; COLOR: #ff9900; FONT-STYLE: normal; TEXT-DECORATION: underline
}
.org-black:active {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.org-black:hover {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-white:link {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-white:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-white:hover {
 FONT-WEIGHT: normal; COLOR: #ffffff; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-green:link {
 FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-green:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-green:active {
 FONT-WEIGHT: normal; COLOR: #94a857; FONT-STYLE: normal; TEXT-DECORATION: none
}
.black-green:hover {
 FONT-WEIGHT: normal; COLOR: #94a857; FONT-STYLE: normal; TEXT-DECORATION: none
}
.yellow-white:link {
 FONT-WEIGHT: normal; COLOR: #ffffcc; FONT-STYLE: normal; TEXT-DECORATION: none
}
.yellow-white:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #ffffcc; FONT-STYLE: normal; TEXT-DECORATION: none
}
.yellow-white:hover {
 FONT-WEIGHT: normal; COLOR: #ffffff; FONT-STYLE: normal; TEXT-DECORATION: none
}
.main-bg-news {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-about {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../aboutus/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-loan {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../loan/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-news {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-process {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../process/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-tax {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../tax/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.main-bg-policy {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/main.gif); BACKGROUND-REPEAT: no-repeat
}
.input {
 BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #666666 1px solid; COLOR: #000000; BORDER-BOTTOM: #666666 1px solid; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"; HEIGHT: 18px; BACKGROUND-COLOR: #eeeeee
}
.input2 {
 BORDER-RIGHT: #2c2c94 1px solid; BORDER-TOP: #2c2c94 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #2c2c94 1px solid; COLOR: #eeeeee; BORDER-BOTTOM: #2c2c94 1px solid; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"; HEIGHT: 16px; BACKGROUND-COLOR: #4992bc
}
.bf14 {
 FONT-SIZE: 14px; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"; TEXT-DECORATION: none
}
.or-border {
 BORDER-RIGHT: 1px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 0px solid; BORDER-BOTTOM: 0px solid
}
.l22 {
 LINE-HEIGHT: 20px
}
.hb-line {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot_line.gif); BACKGROUND-REPEAT: repeat-x
}
.wht-line {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot_line_w_v1.gif); BACKGROUND-REPEAT: repeat-x
}
.wv1-line {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot_line_w_h1.gif); BACKGROUND-REPEAT: repeat-y
}
.vr-line {
 BACKGROUND-POSITION: right top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot_line_v.gif); BACKGROUND-REPEAT: repeat-y
}
.bfont-13 {
 FONT-SIZE: 13px; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
.bfont-14 {
 FONT-SIZE: 14px; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
.box_b {
 BORDER-RIGHT: 0px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 0px solid; BORDER-BOTTOM: 1px solid
}
.box_t {
 BORDER-RIGHT: 0px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 0px solid; BORDER-BOTTOM: 0px solid
}
.box_r {
 BORDER-RIGHT: 1px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 0px solid; BORDER-BOTTOM: 0px solid
}
.box_l {
 BORDER-RIGHT: 0px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 0px solid
}
.box-rl {
 BORDER-RIGHT: 1px solid; BORDER-TOP: 0px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 0px solid
}
.line-vb {
 BACKGROUND-POSITION: right top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot_line_hb.gif); BACKGROUND-REPEAT: repeat-y
}
.lineh {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/hline.gif); BACKGROUND-REPEAT: repeat-x
}
.linev {
 BACKGROUND-POSITION: center top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/V_line.jpg); BACKGROUND-REPEAT: repeat-y
}
.linehm {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/hline.gif); BACKGROUND-REPEAT: repeat-x
}
.box {
 BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid
}
.tbb1 {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/tbb1.jpg); BACKGROUND-REPEAT: no-repeat
}
.tbb2 {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/tbb2.jpg); BACKGROUND-REPEAT: no-repeat
}
.input3 {
 BORDER-RIGHT: #666666 1px; BORDER-TOP: #666666 1px; FONT-SIZE: 11px; BORDER-LEFT: #666666 1px; COLOR: #000000; BORDER-BOTTOM: #666666 1px; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"; HEIGHT: 13px; BACKGROUND-COLOR: #eeeeee
}
.2top-bg {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/2top-bg.gif); BACKGROUND-REPEAT: no-repeat
}
.2left-bg {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/2left-bg.gif); BACKGROUND-REPEAT: no-repeat
}
.box-tb {
 BORDER-RIGHT: 0px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 0px solid; BORDER-BOTTOM: 1px solid
}
.r-search-news {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/tbl2.gif); BACKGROUND-REPEAT: no-repeat
}
.r-search-policy {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/tbl2.gif); BACKGROUND-REPEAT: no-repeat
}
.news-tbl-bg {
 BACKGROUND-POSITION: right top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/tbl-bg.gif); BACKGROUND-REPEAT: repeat-x
}
.green-bdline-h {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/green-dl-b.gif); BACKGROUND-REPEAT: repeat-x
}
.green-sdline-h {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/green-dl-s.gif); BACKGROUND-REPEAT: repeat-x
}
.green-sdline-h-b {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/green-dl-s.gif); BACKGROUND-REPEAT: repeat-x
}
.yellow-bdline-h {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/yellow-dl-b.gif); BACKGROUND-REPEAT: repeat-x
}
.yellow-sdline-h {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/yellow-dl-s.gif); BACKGROUND-REPEAT: repeat-x
}
.yellow-sdline-h-b {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../news/pic/yellow-dl-s.gif); BACKGROUND-REPEAT: repeat-x
}
.policy-title-bg {
 BACKGROUND-POSITION: left center; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/title-bg.gif); BACKGROUND-REPEAT: no-repeat
}
.policy-table-bg {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../policy/pic/table-bg.gif); BACKGROUND-REPEAT: no-repeat
}
.l28 {
 FONT-SIZE: 12px; LINE-HEIGHT: 28px; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
.idx-top-bg {
 BACKGROUND-POSITION: center top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/idx_bg.gif); BACKGROUND-REPEAT: no-repeat
}
.tax-bg1 {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../tax/pic/tax-bg1.gif); BACKGROUND-REPEAT: no-repeat
}
.tax-bg2 {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../tax/pic/tax-bg2.gif); BACKGROUND-REPEAT: no-repeat
}
.ref-bg {
 BACKGROUND-POSITION: right top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../referee/pic/bg.gif); BACKGROUND-REPEAT: no-repeat
}
.linehb {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/hline.gif); BACKGROUND-REPEAT: repeat-x
}
.input-org {
 BORDER-RIGHT: #f26522 1px solid; BORDER-TOP: #f26522 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #f26522 1px solid; COLOR: #ffffff; BORDER-BOTTOM: #f26522 1px solid; HEIGHT: 18px; BACKGROUND-COLOR: #f26522
}
.mgz-bg1 {
 BACKGROUND-POSITION: left top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../magazine/pic/bg.gif); BACKGROUND-REPEAT: no-repeat
}
.blue-dl {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot-l-blue.gif); BACKGROUND-REPEAT: repeat-x
}
.org-dl {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot-l-org.gif); BACKGROUND-REPEAT: repeat-x
}
.grn-dl {
 BACKGROUND-POSITION: left bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/dot-l-gre.gif); BACKGROUND-REPEAT: repeat-x
}
.hot-bg {
 BACKGROUND-POSITION: right top; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/idx_hot2.gif); BACKGROUND-REPEAT: no-repeat
}
.nav-bg {
 BACKGROUND-POSITION: right bottom; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url(../img/idx_top_bg.gif); BACKGROUND-REPEAT: no-repeat
}
.white-yellow:link {
 FONT-WEIGHT: normal; COLOR: #ffffff; FONT-STYLE: normal; TEXT-DECORATION: none
}
.white-yellow:visited {
 FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #ffffff; FONT-STYLE: normal; TEXT-DECORATION: none
}
.white-yellow:hover {
 FONT-WEIGHT: normal; COLOR: #ffff00; FONT-STYLE: normal; TEXT-DECORATION: none
}

</style>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JavaScript >
function most(a,b,c){
 var result=a;
 if(b>result)result=b;
 if(c>result)result=c;
 return result;
}

function interest(){  
 //等额本息法
 //月还款总额
 var loan_a=0;
 var loan_b=0;
 var loan_c=0;
 var year1;      //按揭年数
 var year2;      //公积金贷款年数
 var year3;      //消费贷款年数
 var rate_a=0;          //按揭利息
 var rate_b=0;          //公积金利息
 var rate_c=0;          //消费贷款利息
 var month1=0;
 var monthpay1=0;
 var month2=0;
 var monthpay2=0;
 var month3=0;
 var monthpay3=0;
 var cumulativePrincipal=0;//累积归还本金
 var cumulativeInterest=0;//累积偿付利息
 var cumulativeMonthpay=0;//累积本息总付款额

 var loantotal=form1.loana.value*10000+form1.loanb.value*10000+form1.loanc.value*10000;
 document.all.loantotal.innerText=loantotal+"元";
 if(form1.loana.value!=0&&form1.year1.value!=''){
  loan_a=form1.loana.value*10000;
  year1=form1.year1.value;      //按揭年数
  if(year1<6){
   rate_a=form1.rate1a.value/12;
  }
  else{
   rate_a=form1.rate2a.value/12; 
  }
  month1=year1*12;
  monthpay1=Math.round((loan_a*rate_a/100)*Math.pow((1+rate_a/100),month1)/(Math.pow((1+rate_a/100),month1)-1)*100)/100;
 }

 if(form1.loanb.value!=0&&form1.year2.value!=''){
  loan_b=form1.loanb.value*10000;
  year2=form1.year2.value;      //按揭年数
  if(year2<6){
   rate_b=form1.rate1b.value/12;
  }
  else{
   rate_b=form1.rate2b.value/12;
  }
  month2=year2*12;
  monthpay2=Math.round((loan_b*rate_b/100)*Math.pow((1+rate_b/100),month2)/(Math.pow((1+rate_b/100),month2)-1)*100)/100;
 }

 if(form1.loanc.value!=0&&form1.year3.value!=''){
  loan_c=form1.loanc.value*10000;
  year3=form1.year3.value;      //按揭年数
  if(year3<4){
   rate_c=form1.rate1c.value/12;
  }
  else if(year3>5){
   rate_c=form1.rate3c.value/12;
  }
  else{
   rate_c=form1.rate2c.value/12;
  }
  month3=year3*12;
  monthpay3=Math.round((loan_c*rate_c/100)*Math.pow((1+rate_c/100),month3)/(Math.pow((1+rate_c/100),month3)-1)*100)/100;
 }
 var month=most(month1,month2,month3);
 var monthpay=0;
 var returntotal=monthpay1*month1+monthpay2*month2+monthpay3*month3;
 document.all.returntotal.innerText=Math.round(returntotal)+"元";
 document.all.interesttotal.innerText=Math.round(returntotal-loantotal)+"元";
 
 var interest=0;  //当月归还利息
 var principal=0; //当月归还本金
 var payday=new Date(form1.year.value,form1.month.value);
 var bgcolor='';
 var str='<table border="0" cellpadding="0" cellspacing="1" class="blackfont">';
 for(i=1;i<=month;i++){
  monthpay=0;
  interest=0;
  principal=0;

  //按揭贷款
  if(form1.loana.value!=0&&form1.year1.value!=''&&i<=month1){
   interest+=loan_a*rate_a;
   monthpay+=monthpay1;
   principal+=monthpay1-loan_a*rate_a/100;
   loan_a=Math.round(loan_a*(100+rate_a)-monthpay1*100)/100;
  }
  else{
   loan_a=0;
  }
  
  //公积金贷款
  if(form1.loanb.value!=0&&form1.year2.value!=''&&i<=month2){
   interest+=loan_b*rate_b;
   monthpay+=monthpay2;
   principal+=monthpay2-loan_b*rate_b/100;
   loan_b=Math.round(loan_b*(100+rate_b)-monthpay2*100)/100;
  }
  else{
   loan_b=0;
  }
  
  //消费贷款
  if(form1.loanc.value!=0&&form1.year3.value!=''&&i<=month3){
   interest+=loan_c*rate_c;
   monthpay+=monthpay3;
   principal+=monthpay3-loan_c*rate_c/100;
   loan_c=Math.round(loan_c*(100+rate_c)-monthpay3*100)/100;
  }
  else{
   loan_c=0;
  }

  interest=Math.round(interest)/100;
  principal=Math.round(principal*100)/100;
  cumulativePrincipal+=principal;//累积归还本金
  cumulativeInterest+=interest;//累积偿付利息
  cumulativeMonthpay+=monthpay;//累积本息总付款额

  //灰白相间
  if(i%2==0)bgcolor=' bgcolor="#CCCCCC"';
  else bgcolor='';
  
  //显示
  str=str+'<tr'+bgcolor+'><td width="30">' +i+'</td><td width="90">' +payday.getYear()+'年'+(payday.getMonth()+1)+'月'+'</td><td width="100">';
  str=str+FormatCur(loantotal)+'</td><td width="90">' +FormatCur(principal)+'</td><td width="100">'
   +FormatCur(cumulativePrincipal)+'</td><td width="90">' +FormatCur(interest)+'</td><td width="100">'
   +FormatCur(cumulativeInterest)+'</td><td width="120">' +FormatCur(monthpay)+'</td><td width="120">'
   +FormatCur(cumulativeMonthpay)+'</td></tr>';
  
  payday.setMonth(payday.getMonth()+1);//放贷日
  loantotal=loan_a+loan_b+loan_c;//贷款总额
 }//end for
 str=str+'</table>';
 window.document.all.result.innerHTML=str;
}

function principal(){
 //等额本金法
 //月还款总额
 var loan_a=0;
 var loan_b=0;
 var loan_c=0;
 var year1;      //按揭年数
 var year2;      //公积金贷款年数
 var year3;      //消费贷款年数
 var rate_a=0;          //按揭利息
 var rate_b=0;          //公积金利息
 var rate_c=0;          //消费贷款利息
 var month1=0;
 var monthpay1=0;
 var month2=0;
 var monthpay2=0;
 var month3=0;
 var monthpay3=0;
 var principala;
 var principalb;
 var principalc;
 var cumulativePrincipal=0;//累积归还本金
 var cumulativeInterest=0;//累积偿付利息
 var cumulativeMonthpay=0;//累积本息总付款额

 var loantotal=form1.loana.value*10000+form1.loanb.value*10000+form1.loanc.value*10000;
 document.all.loantotal.innerText=loantotal+"元";
 if(form1.loana.value!=0&&form1.year1.value!=''){
  loan_a=form1.loana.value*10000;
  year1=form1.year1.value;      //按揭年数
  if(year1<6){
   rate_a=form1.rate1a.value/12;
  }
  else{
   rate_a=form1.rate2a.value/12; 
  }
  month1=year1*12;
  principala=Math.round(loan_a/month1*100)/100; //当月归还本金
 }

 if(form1.loanb.value!=0&&form1.year2.value!=''){
  loan_b=form1.loanb.value*10000;
  year2=form1.year2.value;      //按揭年数
  if(year2<6){
   rate_b=form1.rate1b.value/12;
  }
  else{
   rate_b=form1.rate2b.value/12;
  }
  month2=year2*12;
  principalb=Math.round(loan_b/month2*100)/100; //当月归还本金
 }

 if(form1.loanc.value!=0&&form1.year3.value!=''){
  loan_c=form1.loanc.value*10000;
  year3=form1.year3.value;      //按揭年数
  if(year3<4){
   rate_c=form1.rate1c.value/12;
  }
  else if(year3>5){
   rate_c=form1.rate3c.value/12;
  }
  else{
   rate_c=form1.rate2c.value/12;
  }
  month3=year3*12;
  principalc=Math.round(loan_c/month3*100)/100; //当月归还本金
 }
 var month=most(month1,month2,month3);
 
 var principal=0;
 var restloan=loantotal;
 var resta=loan_a;
 var restb=loan_b;
 var restc=loan_c;
 var interest=0;  //当月归还利息
 var payday=new Date(form1.year.value,form1.month.value);
 var bgcolor='';
 var monthpay=0;
 var returntotal=0;
 var str='<table border="0" cellpadding="0" cellspacing="1" class="blackfont">';

 for(i=1;i<=month;i++){
  interest=0;
  principal=0;
  if(form1.loana.value!=0&&form1.year1.value!=''&&i<=month1){
   interest+=resta*rate_a
   principal+=principala;
   resta=Math.round(resta*100-principala*100)/100;
  }
  if(form1.loanb.value!=0&&form1.year2.value!=''&&i<=month2){
   interest+=restb*rate_b
   principal+=principalb;
   restb=Math.round(restb*100-principalb*100)/100;
  }
  if(form1.loanc.value!=0&&form1.year3.value!=''&&i<=month3){
   interest+=restc*rate_c
   principal+=principalc;
   restc=Math.round(restc*100-principalc*100)/100;
  }
  interest=Math.round(interest)/100;
  monthpay=principal+interest;
  returntotal=returntotal+monthpay;
  cumulativePrincipal+=principal;//累积归还本金
  cumulativeInterest+=interest;//累积偿付利息
  cumulativeMonthpay+=monthpay;//累积本息总付款额
  //灰白相间
  if(i%2==0)bgcolor=' bgcolor="#CCCCCC"';
  else bgcolor='';
  
  //显示
  str=str+'<tr'+bgcolor+'><td width="30">' +i+'</td><td width="90">' +payday.getYear()+'年'+(payday.getMonth()+1)+'月'+'</td><td width="100">';
  str=str+FormatCur(restloan)+'</td><td width="90">' +FormatCur(principal)+'</td><td width="100">'
  +FormatCur(cumulativePrincipal)+'</td><td width="90">' +FormatCur(interest)+'</td><td width="100">'
   +FormatCur(cumulativeInterest)+'</td><td width="120">' +FormatCur(monthpay)+'</td><td width="120">'
   +FormatCur(cumulativeMonthpay)+'</td></tr>';
  
  payday.setMonth(payday.getMonth()+1);//放贷日
  restloan=restloan-principal;//剩余贷款
 }//end for

 str=str+'</table>';
 document.all.returntotal.innerText=Math.round(returntotal)+"元";
 document.all.interesttotal.innerText=Math.round(returntotal-loantotal)+"元";
 window.document.all.result.innerHTML=str;
}

function caculate(){
 if(form1.loana_input.value==''&&form1.loanb_input.value==''&&form1.loanc_input.value==''){
  alert("商业贷款或者公积金贷款或者消费贷款\n至少必须输入一项才能进行计算!");
  form1.loana_input.focus();
  return;
 }
 
 //商业贷款校验
 if(form1.loana_input.value!=''){
  if(String(parseFloat(form1.loana_input.value))=="NaN"){
   alert("商业贷款金额不正确!");
   form1.loana_input.value="";
   form1.loana_input.focus();
   return;
  }
  if(form1.year1.value!=''){
   if(String(parseFloat(form1.year1.value))=="NaN"){
    alert("商业贷款年限不正确!");
    form1.year1.value="";
    form1.year1.focus();
    return;
   }
   if(parseFloat(form1.year1.value)>30){
    alert("商业贷款年限不能超过30年!");
    form1.year1.value="";
    form1.year1.focus();
    return;
   }
  }
  else{
   alert("您还没有输入商业贷款年限!");
   form1.year1.focus();
   return;
  }
  form1.loana.value=form1.loana_input.value;
 }
 else{
  form1.loana.value=0;
  form1.year1.value='';
 }

 //公积金贷款校验
 if(form1.loanb_input.value!=''){
  if(String(parseFloat(form1.loanb_input.value))=="NaN"){
   alert("公积金贷款金额不正确!");
   form1.loanb_input.value="";
   form1.loanb_input.focus();
   return;
  }
  if(form1.year2.value!=''){
   if(String(parseFloat(form1.year2.value))=="NaN"){
    alert("公积金贷款年限不正确!");
    form1.year2.value="";
    form1.year2.focus();
    return;
   }
   if(parseFloat(form1.year2.value)>30){
    alert("公积金贷款年限不能超过30年!");
    form1.year2.value="";
    form1.year2.focus();
    return;
   }
  }
  else{
   alert("您还没有输入公积金贷款年限!");
   form1.year2.focus();
   return;
  }
  form1.loanb.value=form1.loanb_input.value;
 }
 else{
  form1.loanb.value=0;
  form1.year2.value='';
 }
 
 //消费贷款校验
 if(form1.loanc_input.value!=''){
  if(String(parseFloat(form1.loanc_input.value))=="NaN"){
   alert("消费贷款金额不正确!");
   form1.loanc_input.value="";
   form1.loanc_input.focus();
   return;
  }
  if(form1.year3.value!=''){
   if(String(parseFloat(form1.year3.value))=="NaN"){
    alert("消费贷款年限不正确!");
    form1.year3.value="";
    form1.year3.focus();
    return;
   }
   if(parseFloat(form1.year3.value)>30){
    alert("消费贷款年限不能超过30年!");
    form1.year3.value="";
    form1.year3.focus();
    return;
   }
  }
  else{
   alert("您还没有输入消费贷款年限!");
   form1.year3.focus();
   return;
  }
  form1.loanc.value=form1.loanc_input.value;
 }
 else{
  form1.loanc.value=0;
  form1.year3.value='';
 }

 if(form1.type.value==1)interest();
 else principal();
}

function caculate1(){
 //商业贷款校验
 if(form1.loana_input.value!=''){
  if(String(parseFloat(form1.loana_input.value))=="NaN"){
   alert("商业贷款金额不正确!");
   form1.loana_input.value="";
   form1.loana_input.focus();
   return;
  }
  form1.loana.value=form1.loana_input.value;
 }
 else{
  alert("您还没有输入商业贷款金额!");
  form1.loana_input.focus();
  return;
 }
 if(form1.year1.value!=''){
  if(String(parseFloat(form1.year1.value))=="NaN"){
   alert("商业贷款年限不正确!");
   form1.year1.value="";
   form1.year1.focus();
   return;
  }
  if(parseFloat(form1.year1.value)>30){
   alert("商业贷款年限不能超过30年!");
   form1.year1.value="";
   form1.year1.focus();
   return;
  }
 }
 else{
  alert("您还没有输入商业贷款年限!");
  form1.year1.focus();
  return;
 }

 form1.loanb.value=0;
 form1.loanc.value=0;
 if(form1.type.value==1)interest();
 else principal();
}

function caculate2(){
 //公积金贷款校验
 if(form1.loanb_input.value!=''){
  if(String(parseFloat(form1.loanb_input.value))=="NaN"){
   alert("公积金贷款金额不正确!");
   form1.loanb_input.value="";
   form1.loanb_input.focus();
   return;
  }
  form1.loanb.value=form1.loanb_input.value;
 }
 else{
  alert("您还没有输入公积金贷款金额!");
  form1.loanb_input.focus();
  return;
 }
 if(form1.year2.value!=''){
  if(String(parseFloat(form1.year2.value))=="NaN"){
   alert("公积金贷款年限不正确!");
   form1.year2.value="";
   form1.year2.focus();
   return;
  }
  if(parseFloat(form1.year2.value)>30){
   alert("公积金贷款年限不能超过30年!");
   form1.year2.value="";
   form1.year2.focus();
   return;
  }
 }
 else{
  alert("您还没有输入公积金贷款年限!");
  form1.year2.focus();
  return;
 }
 
 form1.loana.value=0;
 form1.loanc.value=0;
 if(form1.type.value==1)interest();
 else principal();
}

function caculate3(){
 //消费贷款校验
 if(form1.loanc_input.value!=''){
  if(String(parseFloat(form1.loanc_input.value))=="NaN"){
   alert("消费贷款金额不正确!");
   form1.loanc_input.value="";
   form1.loanc_input.focus();
   return;
  }
  form1.loanc.value=form1.loanc_input.value;
 }
 else{
  alert("您还没有输入消费贷款金额!");
  form1.loanc_input.focus();
  return;
 }
 if(form1.year3.value!=''){
  if(String(parseFloat(form1.year3.value))=="NaN"){
   alert("消费贷款年限不正确!");
   form1.year3.value="";
   form1.year3.focus();
   return;
  }
  if(parseFloat(form1.year3.value)>30){
   alert("消费贷款年限不能超过30年!");
   form1.year3.value="";
   form1.year3.focus();
   return;
  }
 }
 else{
  alert("您还没有输入消费贷款年限!");
  form1.year3.focus();
  return;
 }

 form1.loana.value=0;
 form1.loanb.value=0;
 if(form1.type.value==1)interest();
 else principal();
}

function recaculate(){
 form1.reset();
 document.all.loantotal.innerText="";
 document.all.returntotal.innerText="";
 document.all.interesttotal.innerText="";
 document.all.result.innerHTML="";
}

</SCRIPT>

<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</SCRIPT>

<SCRIPT language=VBScript>
Function FormatCur(Value)
FormatCur=FormatCurrency(Value)
End Function
</SCRIPT>

<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</SCRIPT>

<META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD>
<BODY leftMargin=0 topMargin=0>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR>
    <TD vAlign=top align=middle width=740>
      <TABLE cellSpacing=0 cellPadding=20 width=740 border=0>
        <TBODY>
        <TR>
          <TD align=middle><FONT
      size=4><B>贷款还款计算器</B></FONT></TD></TR></TBODY></TABLE>
      <FORM name=form1>
      <TABLE class=blackfont cellSpacing=0 width=740 border=0>
        <TBODY>
        <TR>
          <TD height=17><SPAN class=bfont-13><FONT
            color=#ff6600>目前商业贷款年利率:</FONT></SPAN> </TD></TR>
        <TR>
          <TD><A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>五年以内 <INPUT id=rate12 size=8
            value=4.95 name=rate1a> %; <A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>五年以上 <INPUT id=rate2a size=8
            value=5.31 name=rate2a> %;</TD></TR>
        <TR>
          <TD><FONT color=#ff6600>目前公积金贷款<SPAN class=bfont-13><FONT
            color=#ff6600>年</FONT></SPAN>利率</FONT></TD></TR>
        <TR>
          <TD><A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>五年以内 <INPUT id=rate1 size=8
            value=3.78 name=rate1b> %; <A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>五年以上 <INPUT id=rate2b size=8
            value=4.23 name=rate2b> %;</TD></TR>
        <TR>
          <TD><FONT color=#ff6600>目前消费贷款<SPAN class=bfont-13><FONT
            color=#ff6600>年</FONT></SPAN>利率</FONT></TD></TR>
        <TR>
          <TD><A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>1~3年 <INPUT id=rate1 size=8
            value=5.76 name=rate1c> %; <A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>4~5年 <INPUT id=rate2c size=8
            value=5.85 name=rate2c> %;<A
            href="http://www.coldwellbanker.com.cn/loan/article.asp"><FONT
            color=#ff9900 size=3>&#8226;</FONT></A>6~10年 <INPUT id=rate3c size=8
            value=6.12 name=rate3c> %;</TD></TR>
        <TR>
          <TD width=500>如果利率变动,请输入新的利率。</TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width=740 border=0>
        <TBODY>
        <TR>
          <TD vAlign=bottom align=middle width=500></TD></TR>
        <TR>
          <TD width=500>
            <TABLE cellSpacing=0 cellPadding=0 width=500 border=0>
              <TBODY>
              <TR>
                <TD align=left width=1 height=114></TD>
                <TD vAlign=top borderColor=#ff9900 align=middle width=349
                bgColor=#ffff88>
                  <TABLE class=blackfont cellSpacing=0 width="96%" border=0>
                    <TBODY>
                    <TR>
                      <TD class=bfont-13 colSpan=4><FONT
                        color=#ff6600><B>参数选择</B> </FONT></TD></TR>
                    <TR>
                      <TD>贷款方式</TD>
                      <TD><SELECT id=select7 name=type> <OPTION value=1
                          selected>等额本息法</OPTION> <OPTION
                        value=2>等额本金法</OPTION></SELECT></TD>
                      <TD>&nbsp;</TD>
                      <TD>&nbsp;</TD></TR>
                    <TR>
                      <TD>商业贷款</TD>
                      <TD><INPUT id=loana_input maxLength=12 size=12
                        name=loana_input> 万元</TD>
                      <TD>按揭</TD>
                      <TD><INPUT id=year1 maxLength=2 size=3 name=year1> 年
                    </TD></TR>
                    <TR>
                      <TD>公积金</TD>
                      <TD><INPUT id=loanb_input maxLength=12 size=12
                        name=loanb_input> 万元</TD>
                      <TD>年限</TD>
                      <TD><INPUT id=year2 maxLength=2 size=3 name=year2> 年
                    </TD></TR>
                    <TR>
                      <TD>消费贷款</TD>
                      <TD><INPUT id=loanc_input maxLength=12 size=12
                        name=loanc_input> 万元</TD>
                      <TD>年限</TD>
                      <TD><INPUT id=year3 maxLength=2 size=3 name=year3> 年
                    </TD></TR>
                    <TR>
                      <TD>放款日期</TD>
                      <TD><SELECT name=year></SELECT> 年 <SELECT name=month>
                          <OPTION value=1 selected>01</OPTION> <OPTION
                          value=2>02</OPTION> <OPTION value=3>03</OPTION>
                          <OPTION value=4>04</OPTION> <OPTION
                          value=5>05</OPTION> <OPTION value=6>06</OPTION>
                          <OPTION value=7>07</OPTION> <OPTION
                          value=8>08</OPTION> <OPTION value=9>09</OPTION>
                          <OPTION value=10>10</OPTION> <OPTION
                          value=11>11</OPTION> <OPTION
                        value=12>12</OPTION></SELECT> 月</TD>
                      <TD>&nbsp;</TD>
                      <TD><INPUT id=loana type=hidden value=0 name=loana>
                        <INPUT id=loanb type=hidden value=0 name=loanb> <INPUT
                        id=loanc type=hidden value=0
                  name=loanc></TD></TR></TBODY></TABLE></TD>
                <TD vAlign=top align=middle width=140 bgColor=#88ff88>
                  <TABLE cellSpacing=0 width="100%" bgColor=#88ff88 border=0>
                    <TBODY>
                    <TR>
                      <TD align=middle width="53%" height=25><INPUT class=whitebutton onclick=javascript:caculate() type=button value="总 贷 款 计 算" name=button>
                      </TD></TR>
                    <TR>
                      <TD align=middle height=25><INPUT class=whitebutton onclick=javascript:caculate1() type=button value=" 商业贷款计算 " name=button3></TD></TR>
                    <TR>
                      <TD align=middle height=25><INPUT class=whitebutton onclick=javascript:caculate2() type=button value=公积金贷款计算 name=button4></TD></TR>
                    <TR>
                      <TD align=middle height=25><INPUT class=whitebutton onclick=javascript:caculate3() type=button value=" 消费贷款计算 " name=button5></TD></TR>
                    <TR>
                      <TD align=middle height=25><INPUT class=whitebutton onclick=javascript:recaculate(); type=button value="  重 新 计 算 " name=button2></TD></TR></TBODY></TABLE></TD>
                <TD width=1></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD vAlign=top align=middle width=500></TD></TR></TBODY></TABLE></FORM>
      <TABLE class=blackfont cellSpacing=0 width=740 border=0>
        <TBODY>
        <TR>
          <TD class=bfont-13 colSpan=3><FONT
          color=#ff6600><B>计算结果:</B></FONT></TD>
          <TD id=status colSpan=3>&nbsp;</TD></TR>
        <TR class=hb-line>
          <TD width=60><FONT color=#ff6600>贷款总额:</FONT></TD>
          <TD id=loantotal>&nbsp;</TD>
          <TD width=60><FONT color=#ff6600>还款总额:</FONT></TD>
          <TD id=returntotal>&nbsp;</TD>
          <TD width=60><FONT color=#ff6600>支付息款:</FONT></TD>
          <TD id=interesttotal>&nbsp;</TD></TR></TBODY></TABLE>
      <TABLE height=300 cellSpacing=0 cellPadding=0 align=center border=0>
        <TBODY>
        <TR>
          <TD height=20>
            <TABLE cellSpacing=1 cellPadding=0 border=0>
              <TBODY>
              <TR align=middle>
                <TD width=20 bgColor=#ff9900 height=20>NO</TD>
                <TD width=90 bgColor=#ff9900 height=20>还款时间</TD>
                <TD width=100 bgColor=#ff9900 height=20>贷款余额</TD>
                <TD width=90 bgColor=#99ff00 height=20>每月归还本金</TD>
                <TD width=100 bgColor=#99ff00 height=20>累积归还本金</TD>
                <TD width=90 bgColor=#ff00ff height=20>每月偿付利息</TD>
                <TD width=100 bgColor=#ff00ff height=20>累积偿付利息</TD>
                <TD width=120 bgColor=#ff3300 height=20>每月本息总付款额</TD>
                <TD width=120 bgColor=#ff3300
            height=20>累积本息总付款额</TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD>
            <DIV id=result
        style="OVERFLOW: auto; HEIGHT: 280px"></DIV></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=top align=left width=20>&nbsp;</TD></TR>
  <TR>
    <TD width=200 bgColor=#d6d6d6 height=8></TD>
    <TD width=540 bgColor=#d6d6d6 height=8></TD>
    <TD width=20 bgColor=#d6d6d6></TD></TR></TBODY></TABLE>
<STYLE type=text/css>TD {
 FONT-SIZE: 12px; LINE-HEIGHT: 20px; FONT-STYLE: normal; FONT-FAMILY: "Arial", "Helvetica", "sans-serif"
}
.style2 {
 COLOR: #ffffff
}
</STYLE>

<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</SCRIPT>

<SCRIPT language=JavaScript>
today=new Date();
year=today.getYear();
for(i=1995;i<year+4;i++){
 form1.year.options.add(new Option(i,i));
}
form1.year.options[year-1995].selected=true;
</SCRIPT>
</BODY></HTML>

本文地址:http://com.8s8s.com/it/it31057.htm