📄 calc2.aspx
字号:
<%@ Register TagPrefix="uc1" TagName="Foot" Src="../Inc/Foot.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Head" Src="../Inc/Head.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>购房计算器——等额本金还款法</TITLE>
<link href="../Css/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function exc_zuhe(fmobj,v){
//var fmobj=document.calc1;
if (fmobj.name=="calc1"){
if (v==3){
document.all.calc1_zuhe.style.display='block';
fmobj.jisuan_radio[1].checked = true;
exc_js(fmobj,2);
}else{document.all.calc1_zuhe.style.display='none';}
}else{
if (v==3){
document.all.calc2_zuhe.style.display='block';
fmobj.jisuan_radio[1].checked = true;
exc_js(fmobj,2);
}else{document.all.calc2_zuhe.style.display='none';}
}
}
function exc_js(fmobj,v){
//var fmobj=document.calc1;
if (fmobj.name=="calc1"){
if (v==1){
document.all.calc1_js_div1.style.display='block';
document.all.calc1_js_div2.style.display='none';
document.all.calc1_zuhe.style.display='none';
fmobj.type.value=1;
}else{
document.all.calc1_js_div1.style.display='none';
document.all.calc1_js_div2.style.display='block';
}
}else{
if (v==1){
document.all.calc2_js_div1.style.display='block';
document.all.calc2_js_div2.style.display='none';
document.all.calc2_zuhe.style.display='none';
fmobj.type.value=1;
}else{
document.all.calc2_js_div1.style.display='none';
document.all.calc2_js_div2.style.display='block';
}
}
}
function formReset(fmobj){
//var fmobj=document.calc1;
if (fmobj.name=="calc1"){
document.all.calc1_js_div1.style.display='block';
document.all.calc1_js_div2.style.display='none';
document.all.calc1_zuhe.style.display='none';
document.all.calc1_benjin.style.display='none';
}else{
document.all.calc2_js_div1.style.display='block';
document.all.calc2_js_div2.style.display='none';
document.all.calc2_zuhe.style.display='none';
document.all.calc2_benxi.style.display='none';
}
}
//显示右边的比较div
function showRightDiv(fmobj){
if (ext_total(fmobj)==false){return;}
//alert(document.calc1.month_money2.value);
var a=window.open('','calc_win','status=yes,scrollbars=yes,resizable=yes,width=550,height=500,left=0,top=0')//790*520
if (fmobj.name=="calc1"){
document.calc1.target = "calc_win";
document.calc1.submit();
}else{
document.calc2.target = "calc_win";
document.calc2.submit();
}
}
//验证是否为数字
function reg_Num(str){
if (str.length==0){return false;}
var Letters = "1234567890.";
for (i=0;i<str.length;i++){
var CheckChar = str.charAt(i);
if (Letters.indexOf(CheckChar) == -1){return false;}
}
return true;
}
//得到利率
function getlilv(lilv_class,type,years){
var lilv_class = parseInt(lilv_class);//新旧利率。1:旧利率,2:新利率
if (lilv_class==2){
//2005年 1月的新利率
if (years<=5){
if (type==2){
return 0.0378;//公积金 1~5年 3.78%
}else{
return 0.0495;//商贷 1~5年 4.95%
}
}else{
if (type==2){
return 0.0423//公积金 5-30年 4.23%
}else{
return 0.0531//商贷 5-30年 5.31%
}
}
}else{
//2004年之前的旧利率
if (years<=5){
if (type==2){
return 0.0360//公积金 1~5年 3.60%
}else{
return 0.0477//商贷 1~5年 4.77%
}
}else{
if (type==2){
return 0.0405//公积金 5-30年 4.05%
}else{
return 0.0504//商贷 5-30年 5.04%
}
}
}
}
//本金还款的月还款额(参数: 年利率 / 贷款总额 / 贷款总月份 / 贷款当前月0~length-1)
function getMonthMoney2(lilv,total,month,cur_month){
var lilv_month = lilv / 12;//月利率
//return total * lilv_month * Math.pow(1 + lilv_month, month) / ( Math.pow(1 + lilv_month, month) -1 );
var benjin_money = total/month;
return (total - benjin_money * cur_month) * lilv_month + benjin_money;
}
//本息还款的月还款额(参数: 年利率/贷款总额/贷款总月份)
function getMonthMoney1(lilv,total,month){
var lilv_month = lilv / 12;//月利率
return total * lilv_month * Math.pow(1 + lilv_month, month) / ( Math.pow(1 + lilv_month, month) -1 );
}
function ext_total(fmobj){
//var fmobj=document.calc1;
//先清空月还款数下拉框
while ((k=fmobj.month_money2.length-1)>=0){
fmobj.month_money2.options.remove(k);
}
var years = fmobj.years.value;
var month = fmobj.years.value * 12;
fmobj.month1.value = month+"(月)";
fmobj.month2.value = month+"(月)";
if (fmobj.type.value == 3 ){
//-- 组合型贷款(组合型贷款的计算,只和商业贷款额、和公积金贷款额有关,和按贷款总额计算无关)
if (!reg_Num(fmobj.total_sy.value)){alert("混合型贷款请填写商贷比例");fmobj.total_sy.focus();return false;}
if (!reg_Num(fmobj.total_gjj.value)){alert("混合型贷款请填写公积金比例");fmobj.total_gjj.focus();return false;}
if (fmobj.total_sy.value==null){fmobj.total_sy.value=0;}
if (fmobj.total_gjj.value==null){fmobj.total_gjj.value=0;}
var total_sy = fmobj.total_sy.value;
var total_gjj = fmobj.total_gjj.value;
fmobj.fangkuan_total1.value = "略";//房款总额
fmobj.fangkuan_total2.value = "略";//房款总额
fmobj.money_first1.value = 0;//首期付款
fmobj.money_first2.value = 0;//首期付款
//贷款总额
var total_sy = parseInt(fmobj.total_sy.value);
var total_gjj = parseInt(fmobj.total_gjj.value);
var daikuan_total = total_sy + total_gjj;
fmobj.daikuan_total1.value = daikuan_total;
fmobj.daikuan_total2.value = daikuan_total;
//月还款
var lilv_sd = getlilv(fmobj.lilv.value,1, years);//得到商贷利率
var lilv_gjj = getlilv(fmobj.lilv.value,2, years);//得到公积金利率
//1.本金还款
//月还款
var all_total2 = 0;
var month_money2 = "";
for(j=0;j<month;j++) {
//调用函数计算: 本金月还款额
huankuan = getMonthMoney2(lilv_sd,total_sy,month,j) + getMonthMoney2(lilv_gjj,total_gjj,month,j);
all_total2 += huankuan;
huankuan = Math.round(huankuan*100)/100;
//fmobj.month_money2.options[j] = new Option( (j+1) +"月," + huankuan + "(元)", huankuan);
month_money2 += (j+1) +"月," + huankuan + "(元)\n";
}
fmobj.month_money2.value = month_money2;
//还款总额
fmobj.all_total2.value = Math.round(all_total2*100)/100;
//支付利息款
fmobj.accrual2.value = Math.round( (all_total2 - daikuan_total) *100)/100;
//2.本息还款
//月均还款
var month_money1 = getMonthMoney1(lilv_sd,total_sy,month) + getMonthMoney1(lilv_gjj,total_gjj,month);//调用函数计算
fmobj.month_money1.value = Math.round(month_money1*100)/100 + "(元)";
//还款总额
var all_total1 = month_money1 * month;
fmobj.all_total1.value = Math.round(all_total1*100)/100;
//支付利息款
fmobj.accrual1.value = Math.round( (all_total1 - daikuan_total) *100)/100;
}else{
//-- 商业贷款、公积金贷款
var lilv = getlilv(fmobj.lilv.value,fmobj.type.value, fmobj.years.value);//得到利率
if (fmobj.jisuan_radio[0].checked == true){
//------------ 根据单价面积计算
if (!reg_Num(fmobj.price.value)){alert("请填写单价");fmobj.price.focus();return false;}
if (!reg_Num(fmobj.sqm.value)){alert("请填写面积");fmobj.sqm.focus();return false;}
//房款总额
var fangkuan_total = fmobj.price.value * fmobj.sqm.value;
fmobj.fangkuan_total1.value = fangkuan_total;
fmobj.fangkuan_total2.value = fangkuan_total;
//贷款总额
var daikuan_total = (fmobj.price.value * fmobj.sqm.value) * (fmobj.anjie.value/10);
fmobj.daikuan_total1.value = daikuan_total;
fmobj.daikuan_total2.value = daikuan_total;
//首期付款
var money_first = fangkuan_total - daikuan_total;
fmobj.money_first1.value = money_first
fmobj.money_first2.value = money_first;
}else{
//------------ 根据贷款总额计算
if (fmobj.daikuan_total000.value.length==0){alert("请填写贷款总额");fmobj.daikuan_total000.focus();return false;}
//房款总额
fmobj.fangkuan_total1.value = "略";
fmobj.fangkuan_total2.value = "略";
//贷款总额
var daikuan_total = fmobj.daikuan_total000.value;
fmobj.daikuan_total1.value = daikuan_total;
fmobj.daikuan_total2.value = daikuan_total;
//首期付款
fmobj.money_first1.value = 0;
fmobj.money_first2.value = 0;
}
//1.本金还款
//月还款
var all_total2 = 0;
var month_money2 = "";
for(j=0;j<month;j++) {
//调用函数计算: 本金月还款额
huankuan = getMonthMoney2(lilv,daikuan_total,month,j);
all_total2 += huankuan;
huankuan = Math.round(huankuan*100)/100;
//fmobj.month_money2.options[j] = new Option( (j+1) +"月," + huankuan + "(元)", huankuan);
month_money2 += (j+1) +"月," + huankuan + "(元)\n";
}
fmobj.month_money2.value = month_money2;
//还款总额
fmobj.all_total2.value = Math.round(all_total2*100)/100;
//支付利息款
fmobj.accrual2.value = Math.round( (all_total2 - daikuan_total) *100)/100;
//2.本息还款
//月均还款
var month_money1 = getMonthMoney1(lilv,daikuan_total,month);//调用函数计算
fmobj.month_money1.value = Math.round(month_money1*100)/100 + "(元)";
//还款总额
var all_total1 = month_money1 * month;
fmobj.all_total1.value = Math.round(all_total1*100)/100;
//支付利息款
fmobj.accrual1.value = Math.round( (all_total1 - daikuan_total) *100)/100;
}
}
</SCRIPT>
<SCRIPT language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -