用web写一个劳务报酬个人所得税计算器
时间: 2023-08-13 17:07:26 浏览: 312
好的,以下是一个简单的劳务报酬个人所得税计算器的Web实现:
HTML代码:
```html
<html>
<head>
<title>劳务报酬个人所得税计算器</title>
</head>
<body>
<h1>劳务报酬个人所得税计算器</h1>
<form>
<label for="income">劳务报酬收入:</label>
<input type="number" id="income" name="income"><br><br>
<label for="deduction">扣除费用:</label>
<input type="number" id="deduction" name="deduction"><br><br>
<button type="button" onclick="calculate()">计算</button><br><br>
<label for="tax">个人所得税:</label>
<input type="text" id="tax" name="tax" readonly>
</form>
<script>
function calculate() {
var income = document.getElementById("income").value;
var deduction = document.getElementById("deduction").value;
var taxableIncome = income - deduction;
var tax = 0;
if (taxableIncome <= 0) {
tax = 0;
} else if (taxableIncome <= 3000) {
tax = taxableIncome * 0.03;
} else if (taxableIncome <= 12000) {
tax = taxableIncome * 0.1 - 210;
} else if (taxableIncome <= 25000) {
tax = taxableIncome * 0.2 - 1410;
} else if (taxableIncome <= 35000) {
tax = taxableIncome * 0.25 - 2660;
} else if (taxableIncome <= 55000) {
tax = taxableIncome * 0.3 - 4410;
} else if (taxableIncome <= 80000) {
tax = taxableIncome * 0.35 - 7160;
} else {
tax = taxableIncome * 0.45 - 15160;
}
document.getElementById("tax").value = tax.toFixed(2);
}
</script>
</body>
</html>
```
JavaScript代码:
```javascript
function calculate() {
var income = document.getElementById("income").value;
var deduction = document.getElementById("deduction").value;
var taxableIncome = income - deduction;
var tax = 0;
if (taxableIncome <= 0) {
tax = 0;
} else if (taxableIncome <= 3000) {
tax = taxableIncome * 0.03;
} else if (taxableIncome <= 12000) {
tax = taxableIncome * 0.1 - 210;
} else if (taxableIncome <= 25000) {
tax = taxableIncome * 0.2 - 1410;
} else if (taxableIncome <= 35000) {
tax = taxableIncome * 0.25 - 2660;
} else if (taxableIncome <= 55000) {
tax = taxableIncome * 0.3 - 4410;
} else if (taxableIncome <= 80000) {
tax = taxableIncome * 0.35 - 7160;
} else {
tax = taxableIncome * 0.45 - 15160;
}
document.getElementById("tax").value = tax.toFixed(2);
}
```
使用JavaScript实现了计算个人所得税的功能,根据输入的劳务报酬收入和扣除费用,计算出应缴纳的个人所得税,并将结果显示在页面上。
阅读全文