if else 实现计算个人所得税

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p><h3>上税金额=(实际工资-起征税)*税率-扣除数</h3></p>
<p><h3>应发工资=实际工资-[(实际工资-起征税)*税率-扣除数]</h3></p>
<p><input type="text" name="" id="sl" value="" placeholder="请输入实际工资" /></p>
<p><input type="button" name="result" id="result" value="提交" onclick="fun()" /></p>
<p>您所要上的税为: <span id="res">0.0元</span></p>
<p>最终您所得到的工资为:<span id="salary">0.0元</span></p>
<script type="text/javascript">
function fun() {
var a=document.getElementById("sl").value;
var jg=document.getElementById("result");
if(a<=3500)
{
var res=(a-3500)*0-0;
var salary=a-(a-3500)*0-0;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if(a<=5000)
{
var res=(a-3500)*0.03-0;
var salary=a-(a-3500)*0.03-0;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if(a<=8000)
{
var res=(a-3500)*0.1-105;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if (a<=12500) {
var res=(a-3500)*0.2-555;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if (a<=38500) {
var res=(a-3500)*0.25-1055;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if (a<=58500) {
var res=(a-3500)*0.3-2755;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else if (a<=83500) {
var res=(a-3500)*0.35-5505;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}
else {
var res=(a-3500)*0.45-13505;
var salary=a-res;
document.getElementById("res").innerHTML=res;
document.getElementById("salary").innerHTML=salary;
}

}
</script>
</body>
</html>

posted @ 2017-12-18 13:34  燕林夕  阅读(1354)  评论(0编辑  收藏  举报