JavaScript个人所得税计算(附代码)

JavaScript018

JavaScript个人所得税计算(附代码),第1张

请输入数据:<input id="zgz" name="zgz" onfocus="s()" value="4000"/>

<script type="text/javascript">

<!--

function s()

{

var shuishou=0

var v=document.getElementById('zgz').value

var z=parseInt(v)? v : 0

var chaoguo=z-2000

if (chaoguo >100000)

shuishou += (chaoguo - 100000) * 0.45 + 20000 * 0.4 + 20000 * 0.35 + 20000 * 0.3 + 20000 * 0.25 + 15000 * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >80000 &&chaoguo <= 100000)

shuishou += (chaoguo - 80000) * 0.4 + 20000 * 0.35 + 20000 * 0.3 + 20000 * 0.25 + 15000 * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >60000 &&chaoguo <= 80000)

shuishou += (chaoguo - 60000) * 0.35 + 20000 * 0.3 + 20000 * 0.25 + 15000 * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >40000 &&chaoguo <= 60000)

shuishou += (chaoguo - 40000) * 0.3 + 20000 * 0.25 + 15000 * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >20000 &&chaoguo <= 40000)

shuishou += (chaoguo - 20000) * 0.25 + 15000 * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >5000 &&chaoguo <= 20000)

shuishou += (chaoguo - 5000) * 0.2 + 3000 * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >2000 &&chaoguo <= 5000)

shuishou += (chaoguo - 2000) * 0.15 + 1500 * 0.1 + 500 * 0.05

else if (chaoguo >500 &&chaoguo <= 2000 )

shuishou += (chaoguo - 500) * 0.1 + 500 * 0.05

else if (chaoguo >0 &&chaoguo <= 500 )

shuishou = chaoguo * 0.05

document.getElementById('zgz').value=shuishou

}

-->

</script>

已经给楼主写好了。。。

祝楼主早日成功哈!!!

<!DOCTYPE html>

<html>

<head>

    <meta http-equiv="Content-Type" content="text/html charset=UTF-8">

    <title>RunJS 演示代码</title>

    <script>

        onload = function() {

            var tb = document.getElementById("tb")

            var trs = tb.rows

            for (var i = 0 i < trs.length i++) {

                var tds = trs[i].cells

                for (var j = 1 j < tds.length j++) {

                    var txt = tds[j].children[0]

                    if (null != txt && txt.type == 'text') {

                        if (j > 2 || i == trs.length - 1) {

                            txt.setAttribute("readonly", true)

                        } else {

                            txt.ind = j

                            txt.onkeyup = txt.onfocus = function() {

                                var row = this.parentElement.parentElement

                                var c = row.cells

                                var sum = (c[1].children[0].value * 1 + c[2].children[0].value * 1)

                                var sf = sum * 0.03

                                c[3].children[0].value = sf.toFixed(2)

                                c[4].children[0].value = sum.toFixed(2)

                                c[5].children[0].value = (sf + sum).toFixed(2)

                                var cc = trs[trs.length - 1].cells

                                var total = 0

                                for (var k = 1 k < trs.length - 1 k++) {

                                    total += trs[k].cells[this.ind].children[0].value * 1

                                }

                                cc[this.ind].children[0].value = total

                                sum = (cc[1].children[0].value * 1 + cc[2].children[0].value * 1)

                                sf = sum * 0.03

                                cc[3].children[0].value = sf.toFixed(2)

                                cc[4].children[0].value = sum.toFixed(2)

                                cc[5].children[0].value = (sf + sum).toFixed(2)

                            }

                        }

                    }

                }

            }

        }

    </script>

</head>

<body>

    <table id="tb" width="1000" border="0" cellspacing="0" cellpadding="0">

        <tr>

            <td width="200" align="center">姓名</td>

            <td width="200" align="center">保险</td>

            <td width="200" align="center">工资</td>

            <td width="200" align="center">税费</td>

            <td width="200" align="center">工资保险合计</td>

            <td width="200" align="center">工资、保险、税费合计</td>

        </tr>

        <tr>

            <td width="200" align="center">张三</td>

            <td width="200" align="center">

                <input name="bx1" type="text" id="bx1" value="1500">

            </td>

            <td width="200" align="center">

                <input name="gz1" type="text" id="gz1" value="2000">

            </td>

            <td width="200" align="center">

                <input type="text" name="sf1" id="sf1">

            </td>

            <td width="200" align="center">

                <input type="text" name="gzbxhj1" id="gzbxhj1">

            </td>

            <td width="200" align="center">

                <input type="text" name="gzbxsfhj1" id="gzbxsfhj1">

            </td>

        </tr>

        <tr>

            <td width="200" align="center">李四</td>

            <td width="200" align="center">

                <input name="bx2" type="text" id="bx2" value="1460">

            </td>

            <td width="200" align="center">

                <input name="gz2" type="text" id="gz2" value="2500">

            </td>

            <td width="200" align="center">

                <input type="text" name="sf2" id="sf2">

            </td>

            <td width="200" align="center">

                <input type="text" name="gzbxhj2" id="gzbxhj2">

            </td>

            <td width="200" align="center">

                <input type="text" name="gzbxsfhj2" id="gzbxsfhj2">

            </td>

        </tr>

        <tr>

            <td width="200" align="center" bgcolor="#0066FF">合计</td>

            <td width="200" align="center" bgcolor="#0066FF">

                <input name="bxhj" type="text" id="bxhj">

            </td>

            <td width="200" align="center" bgcolor="#0066FF">

                <input name="gzhj" type="text" id="gzhj">

            </td>

            <td width="200" align="center" bgcolor="#0066FF">

                <input type="text" name="sfsj" id="sfsj">

            </td>

            <td width="200" align="center" bgcolor="#0066FF">

                <input type="text" name="gzbxhjhj" id="gzbxhjhj">

            </td>

            <td width="200" align="center" bgcolor="#0066FF">

                <input type="text" name="gzbxsfhjhj" id="gzbxsfhjhj">

            </td>

        </tr>

    </table>

</body>

</html>