Maison >interface Web >js tutoriel >Javascript implémente le calcul des compétences en matière d'impôt sur le revenu des personnes physiques_javascript
TABLE { BORDER-RIGHT: medium none; PADDING-RIGHT: 0px; BORDER-TOP: medium none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: medium none; PADDING-TOP: 0px;
CSS :
BORDER-BOTTOM: medium none } TD { BORDER-RIGHT: medium none; PADDING-RIGHT: 0px; BORDER-TOP: medium none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: medium none; PADDING-TOP: 0px;BORDER-BOTTOM: medium none } IMG { BORDER-RIGHT: medium none; PADDING-RIGHT: 0px; BORDER-TOP: medium none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: medium none; PADDING-TOP: 0px;BORDER-BOTTOM: medium none } FORM { BORDER-RIGHT: medium none; PADDING-RIGHT: 0px; BORDER-TOP: medium none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: medium none; PADDING-TOP: 0px;BORDER-BOTTOM: medium none } TD { FONT-SIZE: 12px } P { FONT-SIZE: 12px } LI { FONT-SIZE: 12px } SELECT { FONT-SIZE: 12px } INPUT { FONT-SIZE: 12px } TEXTAREA { FONT-SIZE: 12px } SELECT { BORDER-RIGHT: #49b8e3 1px solid; BORDER-TOP: #49b8e3 1px solid; BORDER-LEFT: #49b8e3 1px solid; BORDER-BOTTOM: #49b8e3 1px solid; BACKGROUND-COLOR: #e2f4ff } INPUT { BORDER-RIGHT: #49b8e3 1px solid; BORDER-TOP: #49b8e3 1px solid; BORDER-LEFT: #49b8e3 1px solid; BORDER-BOTTOM: #49b8e3 1px solid; BACKGROUND-COLOR: #e2f4ff } TEXTAREA { BORDER-RIGHT: #49b8e3 1px solid; BORDER-TOP: #49b8e3 1px solid; BORDER-LEFT: #49b8e3 1px solid; BORDER-BOTTOM: #49b8e3 1px solid; BACKGROUND-COLOR: #e2f4ff } .f14 { FONT-SIZE: 14px } .lh19 { LINE-HEIGHT: 19px } A:hover { COLOR: #ff0000 } .b1 { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid } .b2 { BORDER-BOTTOM: #ffffff 1px solid } .b3 { BORDER-RIGHT: #cfe9f8 5px solid; BORDER-TOP: #cfe9f8 5px solid; BORDER-LEFT: #cfe9f8 5px solid; BORDER-BOTTOM: #cfe9f8 5px solid } .cRed { COLOR: #cc0000 } .cGary { COLOR: #6c6c6c } .cBlue { COLOR: #066cd2 } .linkBlankUl A:link { COLOR: #000; TEXT-DECORATION: underline } .linkBlankUl A:visited { COLOR: #000; TEXT-DECORATION: underline } .linkBlankUl A:active { COLOR: #f00; TEXT-DECORATION: underline } .linkBlankUl A:hover { COLOR: #f00; TEXT-DECORATION: underline } .linkBlank A:link { COLOR: #000; TEXT-DECORATION: none } .linkBlank A:visited { COLOR: #000; TEXT-DECORATION: none } .linkBlank A:active { COLOR: #f00; TEXT-DECORATION: none } .linkBlank A:hover { COLOR: #f00; TEXT-DECORATION: none } .linkRed { COLOR: #7b0000 } .linkRed A:link { COLOR: #7b0000; text-: none } .linkRed A:visited { COLOR: #7b0000; text-: none } .linkRed A:active { COLOR: #7b0000; text-: underline } .linkRed A:hover { COLOR: #7b0000; text-: underline } .linkBlue A:link { COLOR: #003399; TEXT-DECORATION: underline } .linkBlue A:visited { COLOR: #003399; TEXT-DECORATION: underline } .linkBlue A:active { COLOR: #0268ce; TEXT-DECORATION: underline } .linkBlue A:hover { COLOR: #0268ce; TEXT-DECORATION: underline }
HTML :
</STYLE> <SCRIPT language=javascript> <!-- function warnInvalid (theField, s) { newAlert(s); theField.focus(); theField.select(); return false; } function isNumber(s) //字符串是否由数字构成 { var digits = "0123456789"; var i = 0; var sLength = s.length; while ((i < sLength)) { var c = s.charAt(i); if (digits.indexOf(c) == -1) return false; i++; } return true; } function CheckNumeric(theField,s) //整数或小数 { var ret = true; var i; var str=theField.value; var Temp = new Number(str); if (str.length == 0) { return warnInvalid (theField, s); ret=false; } if (ret) { if (Temp.valueOf() != Temp.valueOf ()) { return warnInvalid (theField, s); } } return ret; } function validateFormInfo(form) { var str var SumTo var srSum var qzSum,InsuSum,TSum,yzSum,fySum s=document.form1.select.selectedIndex+1; srSum=document.form1.textfield.value; if (s.length<1) { s=1; } qzSum=document.form1.textfield3.value; InsuSum=document.form1.textfield2.value; yzSum=document.form1.textfield22.value; fySum=document.form1.textfield32.value; TSum=srSum-qzSum-InsuSum; /*newAlert_Top("sr="+srSum+"qz="+qzSum+"INsu="+InsuSum+"yz="+yzSum+"fy="+ fySum);*/ if (form == null) return true; str = "请正确输入收入金额!"; if (!CheckNumeric(form.elements ["textfield"],str)) return false; //收入金额 if (document.all.select.selectedIndex==0) { str = "请正确输入社会保险费!"; if (!CheckNumeric(form.elements ["textfield2"],str)) return false; //各项社会保险费 str = "请正确输入起征额!"; if (!CheckNumeric(form.elements ["textfield3"],str)) return false; //起征额 } if (document.all.select.selectedIndex==8) { str = "请正确输入财产原值!"; if (!CheckNumeric(form.elements ["textfield22"],str)) return false; //各项社会保险费 str = "请正确输入合理交易费用!"; if (!CheckNumeric(form.elements ["textfield32"],str)) return false; //起征额 } switch (s) { case 1: document.form1.textfield4.value=Rate1(TSum); break; case 2: document.form1.textfield4.value=Rate2(srSum); break; case 3: document.form1.textfield4.value=Rate2(srSum); break; case 4: document.form1.textfield4.value=Rate3(srSum); break; case 5: document.form1.textfield4.value=R4568(srSum)*70/100; break; case 6: document.form1.textfield4.value=R4568(srSum); break; case 7: document.form1.textfield4.value=srSum*20/100; break; case 8: document.form1.textfield4.value=R4568(srSum); break; case 9: if (srSum-yzSum-fySum<0) { newAlert_Top("都亏了!不用交税了!"); document.form1.textfield4.value=0; } if (srSum-yzSum-fySum>0) { document.form1.textfield4.value= (srSum-yzSum-fySum)*20/100; } break; case 10: document.form1.textfield4.value=srSum*20/100; break; case 11: document.form1.textfield4.value=srSum*20/100; break; } } //--------------------------------以下是算法-------------- //--------------------------------------- function Rate1(XSum)//工资薪金 { var Rate; var Balan; var TSum; if (XSum<=500) {Rate=5; Balan=0; } if ((500<XSum) && (XSum<=2000)) {Rate=10; Balan=25; } if ((2000<XSum) && (XSum<=5000)) {Rate=15; Balan=125; } if ((5000<XSum) && (XSum<=20000)) {Rate=20; Balan=375; } if ((20000<XSum) && (XSum<=40000)) {Rate=25; Balan=1375; } if ((40000<XSum) && (XSum<=60000)) {Rate=30; Balan=3375; } if ((60000<XSum) && (XSum<=80000)) {Rate=35; Balan=6375; } if ((80000<XSum) && (XSum<=100000)) {Rate=40; Balan=10375; } if (XSum>100000) {Rate=45; Balan=15375; } TSum=(XSum*Rate)/100-Balan if (TSum<0) { TSum=0 } return TSum } function Rate2(XSum) { var Rate; var Balan; var TSum; if (XSum<=5000) {Rate=5; Balan=0; } if ((5000<XSum) && (XSum<=10000)) {Rate=10; Balan=250; } if ((10000<XSum) && (XSum<=30000)) {Rate=20; Balan=1250; } if ((30000<XSum) && (XSum<=50000)) {Rate=30; Balan=4250; } if (50000<XSum) {Rate=35; Balan=6750; } TSum=(XSum*Rate)/100-Balan; if (TSum<0) { TSum=0 } return TSum } function R4568(XSum) { var TSum if (XSum<=4000) { TSum=(XSum-2000)*20/100; } if (XSum>4000) { TSum=(XSum-(XSum*20/100))*20/100 } if (TSum<0) { TSum=0 } return TSum } function gong() { var qznum var ff qznum=document.form1.textfield3.value; ff=document.all.checkbox.checked; if (ff) { document.form1.textfield3.value=4000; } if (!ff) { document.form1.textfield3.value=2000; } } function Rate3(XSum)/*劳务报酬*/ { var TSum var Rate var Balan if (XSum<=20000) { Rate=20; Balan=0; } if ((XSum>20000) && (XSum<=50000)) { Rate=30; Balan=2000; } if (XSum>50000) { Rate=40; Balan=7000; } if (XSum<=4000) { XSum=XSum-800; } if (XSum>4000) { XSum=XSum-(XSum*20/100); } TSum=XSum*Rate/100-Balan; if (TSum<0) { TSum=0 } return TSum } function CHan() { if (document.form1.select.selectedIndex==0) { document.all.gongzi.style.display="block"; document.all.fei.style.display="block"; } if (document.form1.select.selectedIndex!=0) { document.all.gongzi.style.display="none"; document.all.fei.style.display="none"; } if (document.form1.select.selectedIndex+1!=9) { document.all.fei1.style.display="none"; } if (document.form1.select.selectedIndex+1==9) { document.all.fei1.style.display="block"; } } //--> </SCRIPT> <script type="text/javascript"> var item=new Array( new Array('银行类工具(存款)',//<-- 大类名,下面几行则为此类下的所有计算器 new Array( new Array('通知存款计算器','http://finance.sina.com.cn/283/2005/0704/2.html'),//<-- 此2项分别为“计算器名”,“链接” new Array('整存零取计算器','http://finance.sina.com.cn/283/2005/0711/24.html'), new Array('最佳存款组合','http://finance.sina.com.cn/283/2005/0711/30.html'), new Array('整(零)存整取计算器','http://finance.sina.com.cn/283/2005/0711/29.html'), new Array('活期储蓄计算器','http://finance.sina.com.cn/283/2005/0711/28.html') //<-- 依次向下罗列,最后一行“)”后没有“,” ) ), //<-- 非结尾大类后有“,” new Array('银行类工具(贷款)',//<-- 另一个大类 new Array( new Array('等额本息还款计算器','http://finance.sina.com.cn/283/2005/0704/3.html'), new Array('等额本金还款计算器','http://finance.sina.com.cn/283/2005/0704/1.html'), new Array('提前还贷计算器','http://finance.sina.com.cn/283/2005/0708/18.html'), new Array('公积金贷款额度年限计算器','http://finance.sina.com.cn/283/2005/0704/6.html')//<-- 最后一行“)”后没有“,” ) ), //<-- 非结尾大类后有“,” new Array('保险类工具',//<-- 另一个大类 new Array( new Array('基本养老保险计算器','http://finance.sina.com.cn/283/2005/0704/10.html'), new Array('基本医疗保险计算器','http://finance.sina.com.cn/283/2005/0708/11.html'), new Array('工伤保险计算器','http://finance.sina.com.cn/283/2005/0704/5.html'), new Array('失业保险','http://finance.sina.com.cn/283/2005/0708/16.html'), new Array('住房公积金计算器','http://finance.sina.com.cn/283/2005/0711/23.html'), new Array('退休时每月领取的养老保险金估算计算器','http://finance.sina.com.cn/283/2005/0708/20.html') ) ), new Array('股票类工具',//<-- 另一个大类 new Array( new Array('股票收益计算器 ','http://finance.sina.com.cn/283/2005/0704/8.html') ) ), new Array('基金类工具',//<-- 另一个大类 new Array( new Array('基金买卖计算器','http://finance.sina.com.cn/283/2005/0708/12.html') ) ), new Array('期货类工具',//<-- 另一个大类 new Array( new Array('期货理财计算器 ','http://finance.sina.com.cn/283/2005/0708/14.html') ) ), new Array('债券类工具',//<-- 另一个大类 new Array( new Array('债券收益率计算器','http://finance.sina.com.cn/283/2005/0711/25.html') ) ), new Array('外汇',//<-- 另一个大类 new Array( new Array('外汇储蓄计算器','http://finance.sina.com.cn/283/2005/0711/27.html'), new Array('外汇兑换计算器','http://finance.sina.com.cn/283/2005/0711/26.html') ) ), new Array('税务类',//<-- 另一个大类 new Array( new Array('买房税费计算器','http://finance.sina.com.cn/283/2005/0708/17.html'), new Array('个人所得税计算器','http://finance.sina.com.cn/283/2005/0704/4.html') ) ), new Array('理财规划类',//<-- 另一个大类 new Array( new Array('理财规划计算器','http://finance.sina.com.cn/283/2005/0708/13.html'), new Array('子女教育基金计算器','http://finance.sina.com.cn/283/2005/0711/21.html'), new Array('投资收益计算器','http://finance.sina.com.cn/283/2005/0708/19.html'), new Array('资产净值计算器','http://finance.sina.com.cn/283/2005/0711/22.html'), new Array('黄金理财计算器','http://finance.sina.com.cn/283/2005/0704/9.html') ) ), new Array('买车计算',//<-- 另一个大类 new Array( new Array('购车综合计算器','http://finance.sina.com.cn/283/2005/0708/15.html') ) ), new Array('购房计算',//<-- 另一个大类 new Array( new Array('购房能力评估计算器','http://finance.sina.com.cn/283/2005/0704/7.html'), new Array('提前还贷计算器','http://finance.sina.com.cn/283/2005/0708/18.html'), new Array('税费计算器','http://finance.sina.com.cn/283/2005/0708/17.html'), new Array('公基金贷款额度年限计算器','http://finance.sina.com.cn/283/2005/0704/6.html'), new Array('等额本金还款法计算器','http://finance.sina.com.cn/283/2005/0704/1.html'), new Array('等额本息还款法计算器','http://finance.sina.com.cn/283/2005/0704/3.html') ) ) ); //-------------- var img0 =new Image(); img0.src="http://image2.sina.com.cn/cj/toolsjs/cj_jsq_lj_010.gif"; var img1 =new Image(); img1.src="http://image2.sina.com.cn/cj/tools4.gif"; function ShowItem (itemId) { for (var i = 0; i < item.length; i++) { eval('document.images["tImg' +i+ '"].src ="http://image2.sina.com.cn/cj/toolsjs/cj_jsq_lj_010.gif"'); eval('document.all.item' + i +'.style.display = "none"'); eval('document.all.menu' + i +'.style.background= "#1e86b0"'); eval('document.all.menu' + i +'.style.color= "#ffffff"'); } eval('document.images["tImg' +itemId + '"].src ="http://image2.sina.com.cn/cj/toolsjs/cj_jsq_lj_011.gif"'); eval('document.all.item' + itemId +'.style.display = "block"'); eval('document.all.menu' + itemId +'.style.background= "#0268CE"'); eval('document.all.menu' +itemId+'.style.color= "#ffffff"'); } </script> <META content="MSHTML 6.00.6000.16640" name=GENERATOR></HEAD> <BODY bgColor=#ffffff topMargin=5 marginheight="5"> <CENTER> <TABLE cellSpacing=0 width=500> <FORM name=form1> <TBODY> <TR> <TD height=1></TD></TR> <TR> <TD> <TABLE style="MARGIN-LEFT: 48px" cellSpacing=0 width=476 align=center> <TBODY> <TR> <TD class=cBlue style="padding-: 7px" vAlign=bottom align=middle height=39><FONT color=#ff00ff size=4> 个人所得税计算公式 </FONT></TD></TR> <TR> <TD background="/OA/images/cj_jsq_lj_006.gif" height=1></TD></TR></TBODY></TABLE> <TABLE class=cBlue style="MARGIN: 18px 0px 10px 38px" cellSpacing=0> <TBODY> <TR> <TD style="padding-: 2px">收入类型:</TD> <TD><SELECT id=select onchange=CHan() name=select> <OPTION value=1 selected>工资、薪金所得<OPTION value=2>个体工商户生产、经营所得<OPTION value=3>对企事业单位的承包经营、承 租经营所得<OPTION value=4>劳务报酬所得<OPTION value=5>稿酬所得<OPTION value=6>特许权使用所得<OPTION value=7>利息、股息、红利所得<OPTION value=8>财产租赁所得<OPTION value=9>财产转让所得<OPTION value=10>偶然所得(如:中奖、中彩)<OPTION value=11>被确定征税的其他部分</OPTION></SELECT></TD></TR> <TR> <TD height=5></TD></TR> <TR> <TD></TD> <TD> <TABLE id=gongzi style="DISPLAY: block" cellSpacing=0 width="100%"><TBODY> <TR> <TD><!--<INPUT name=checkbox onclick=gong() type=checkbox value=checkbox>外籍人员及境外 工作的中国公民--></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD height=10></TD></TR> <TR> <TD class=cBlue style="PADDING-TOP: 2px" width=60>收入金额:</TD> <TD><INPUT id=textfield name=textfield> 元 </TD></TR> <TR> <TD height=12></TD></TR> <TR> <TD colSpan=2> <TABLE class=cblue id=fei style="DISPLAY: block" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD>各项社会保险费: <INPUT id=textfield2 value=0 name=textfield2> <BR></TD></TR> <TR> <TD height=12></TD></TR> <TR> <TD>起 征 额: <INPUT id=textfield3 value=2000 name=textfield3></TD></TR> <TR> <TD><br />注:根据税收规定,个人所得 税的起征点为2000元,2008年3月1日起施行。</TD></TR></TBODY></TABLE></TD></TR> <TR> <TD colSpan=2> <TABLE class=cblue id=fei1 style="DISPLAY: none; MARGIN-LEFT: 43px" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD align=right width=100>财产原值:</TD> <TD><INPUT id=textfield22 value=0 name=textfield22></TD></TR> <TR> <TD height=5></TD></TR> <TR> <TD align=right width=100>合理交易费用:</TD> <TD><INPUT id=textfield33 value=0 name=textfield32></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD height=10></TD></TR> <TR> <TD></TD> <TD><INPUT style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BACKGROUND-IMAGE: url(http://image2.sina.com.cn/cj/toolsjs/cj_jsq_lj_015.gif); BORDER-LEFT: 0px; WIDTH: 47px;CURSOR: pointer; BORDER-BOTTOM: 0px; HEIGHT: 19px" onclick=validateFormInfo(this.form,1) type=button name=button> </TD></TR></TBODY></TABLE></TD></TR> <TR> <TD height=1></TD></TR> <TR> <TD> <TABLE style="MARGIN-LEFT: 48px" cellSpacing=0 width=476> <TBODY> <TR> <TD class=cBlue style="padding-: 7px" vAlign=bottom height=39>计算结果 </TD></TR> <TR> <TD background="/OA/images/cj_jsq_lj_006.gif" height=1></TD></TR></TBODY></TABLE> <TABLE class=cBlue style="MARGIN: 18px 0px 27px 13px" cellSpacing=0> <TBODY> <TR> <TD class=cBlue style="PADDING-TOP: 2px" align=right width=170>您应交纳的个人所得税 为:</TD> <TD><INPUT id=textfield4 name=textfield4> 元 。</TD></TR></TBODY></TABLE></TD></TR></TBODY></FORM></TABLE></CENTER></BODY></HTML>
Ce qui précède représente l’intégralité du contenu de cet article, j’espère que vous l’aimerez tous.