m0_63541669 2021-12-26 18:07 采纳率: 50%
浏览 41
已结题

可以看看为什么计算不出结果吗?

计算不出结果


<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>计算个人所得税</title>
        <style type="text/css">
                body {
                    background-image:url(t4517740429689856.jpg);
                  align-items: center;
                  background-color: skyblue;
                  display: flex;
                  justify-content: center;
                  height: 100vh;
                }
                .box {
                     background-image: url(3.jpg);
                  background-color:palevioletred;
                  border-radius: 20px;
                  box-sizing: border-box;
                  height: 700px;
                  padding: 20px;
                  width: 400px;
                }
                .title {
                  color: indianred;
                  font-family: sans-serif;
                  font-size: 34px;
                  font-weight: 700;
                  margin-top: 20px;
                }
                .box2 {
                  height: 50px;
                  position: relative;
                  width: 100%;
                  }
                  .p1 {
                    margin-top: 40px;
                  }
                  .p2 {
                    margin-top: 30px;
                  }
                  .input {
                    background-color: pink;
                    border-radius: 12px;
                    border: 0;
                    box-sizing: border-box;
                    color: hotpink;
                    font-size: 25px;
                    height: 100%;
                    outline: 0;
                    padding: 4px 20px 0;
                    width: 100%;
                  }
                  .submit {
                    background-color: pink;
                    border-radius: 12px;
                    border: 0;
                    box-sizing: border-box;
                    color: indianred;
                    cursor: pointer;
                    font-size: 25px;
                    height: 50px;
                    margin-top: 38px;
                    text-align: center;
                    width: 100%;
                    -webkit-transition-duration: 0.4s; 
                        transition-duration: 0.4s;
                  }
                  .submit:hover {
                      background-color:hotpink;
                      color: white;
                  }
                  .placeholder{
                      font-size: 18px;
                      color: indianred;
                      font-weight:bold;
                  }
                 
                </style>
                
            </head>
            <body>
                <div class="box">
                <div class="title">
                    请输入你的月工资与年终奖:
                    </div>
                <div class="box2 p1">
                        <input type="text" id="monthIncome" class="input"   placeholder="月工资 " />
                      </div>
                <div class="box2 p2">
                        <input type="text" id="yearIncome" class="input"   placeholder="年终奖 " />
                        
                      </div>     
                <button type="text" class="submit" onclick="printf()">计 算 所 得 税</button>
                      <script type="text/javascript">
                      var table={
                              free:3500
                              levels:[
                                          {low:-3500,high:0,rate:0,sub:0},
                                          {low:0,high:1500,rate:0.03,sub:0},
                                          {low:1500,high:4500,rate:0.1,sub:105},
                                          {low:4500,high:9000,rate:0.2,sub:555},
                                          {low:9000,high:35000,rate:0.25,sub:1005},
                                          {low:35000,high:55000,rate:0.3,sub:2755},
                                          {low:55000,high:80000,rate:0.35,sub:5505},
                                          {low:80000,high:Number.MAX_VALUE,rate:0.45,sub:13505}
                              
                              ],
                              calcMonthTax: function(monthIncome){
                                  var left=monthIncome-this.free;
                                  var tax=0
                                  for(index in this.levels){
                                      if(left>this.levels[index].low &&left<-this.levels[index],high){
                                          tax=left*this.levels[index].rate-this.levels[index].sub;
                                      }
                                  }
                                  return tax;
                              },
                              calcYearTax:function(monthIncome,yearIncome){
                                  var nleft;
                                  var ntax=0
                                  if(monthIncome>=this.free){
                                      for(nindex in this.levels){
                                          nleft=yearIncome/12;
                                          if(nleft>this.levels[nindex].low&&nleft<=this.levels[nindex].high){
                                              ntax=yearIncome*this.levels[nindex].rate-this.levels[nindex].sub;
                                              return ntax
                                          }
                                      }
                                  }
                                  else{
                                      
                                      for(index in this.levels){
                                          yearIncome=yearIncome-(this.free-this.monthIncome)
                                          nleft=yearIncome/12;
                                          if(nleft>this.levels[index].low&&nleft<=this.levels[index].high){
                                              ntax=yearIncome*levels[index].rate-levels[index].sub;
                                              return ntax;
                                          }
                                      }
                                  }
                              }
                          };
                          function printf() {
                              var monthIncome=document.getElementById("monthIncome").value;
                              var yearIncome=document.getElementById("yearIncome").value;
                              var mtax=table.calcMonthTax(monthIncome);var ytax=table.calcYearTax(monthIncome,yearIncome);
                              var all=mmtax*12+ytaxr;
                              document.getElementById("mtax").value=mtax;
                              document.getElementById("ytax").value=ytax;
                              document.getElementById("all").value=all;
                          }
                      }
                      </script>
                <div class="box2 p2">
                        <input type="text" id="mtax" class="input"  placeholder="月税" readonly="readonly" >
                      </div>    
                       <div class="box2 p2">
                               <input type="text" id="ytax" class="input"  placeholder="年税" readonly="readonly" >
                             </div>
    <div class="box2 p2">
            <input type="text" id="all" class="input"  placeholder="全税" readonly="readonly" >
          </div>
    </body>
</html>
<title>计算个人所得税</title>
  • 写回答

2条回答 默认 最新

  • ✎﹏ℳ๓敬坤 2021-12-26 18:52
    关注
    
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>计算个人所得税</title>
            <style type="text/css">
                    body {
                        background-image:url(t4517740429689856.jpg);
                      align-items: center;
                      background-color: skyblue;
                      display: flex;
                      justify-content: center;
                      height: 100vh;
                    }
                    .box {
                         background-image: url(3.jpg);
                      background-color:palevioletred;
                      border-radius: 20px;
                      box-sizing: border-box;
                      height: 700px;
                      padding: 20px;
                      width: 400px;
                    }
                    .title {
                      color: indianred;
                      font-family: sans-serif;
                      font-size: 34px;
                      font-weight: 700;
                      margin-top: 20px;
                    }
                    .box2 {
                      height: 50px;
                      position: relative;
                      width: 100%;
                      }
                      .p1 {
                        margin-top: 40px;
                      }
                      .p2 {
                        margin-top: 30px;
                      }
                      .input {
                        background-color: pink;
                        border-radius: 12px;
                        border: 0;
                        box-sizing: border-box;
                        color: hotpink;
                        font-size: 25px;
                        height: 100%;
                        outline: 0;
                        padding: 4px 20px 0;
                        width: 100%;
                      }
                      .submit {
                        background-color: pink;
                        border-radius: 12px;
                        border: 0;
                        box-sizing: border-box;
                        color: indianred;
                        cursor: pointer;
                        font-size: 25px;
                        height: 50px;
                        margin-top: 38px;
                        text-align: center;
                        width: 100%;
                        -webkit-transition-duration: 0.4s; 
                            transition-duration: 0.4s;
                      }
                      .submit:hover {
                          background-color:hotpink;
                          color: white;
                      }
                      .placeholder{
                          font-size: 18px;
                          color: indianred;
                          font-weight:bold;
                      }
                     
                    </style>
                    
                </head>
                <body>
                    <div class="box">
                    <div class="title">
                        请输入你的月工资与年终奖:
                        </div>
                    <div class="box2 p1">
                            <input type="text" id="monthIncome" class="input"   placeholder="月工资 " />
                          </div>
                    <div class="box2 p2">
                            <input type="text" id="yearIncome" class="input"   placeholder="年终奖 " />
                            
                          </div>     
                    <button type="text" class="submit" onclick="printf()">计 算 所 得 税</button>
         <script type="text/javascript">
            var table={
                free:3500,
                levels:[
                    {low:-3500,high:0,rate:0,sub:0},
                    {low:0,high:1500,rate:0.03,sub:0},
                    {low:1500,high:4500,rate:0.1,sub:105},
                    {low:4500,high:9000,rate:0.2,sub:555},
                    {low:9000,high:35000,rate:0.25,sub:1005},
                    {low:35000,high:55000,rate:0.3,sub:2755},
                    {low:55000,high:80000,rate:0.35,sub:5505},
                    {low:80000,high:Number.MAX_VALUE,rate:0.45,sub:13505}
                                  
                ],
                calcMonthTax: function(monthIncome){
                    var left=monthIncome-this.free;
                    var tax=0
                    for(index in this.levels){
                        if(left>this.levels[index].low &&left<-this.levels[index].high){
                            tax=left*this.levels[index].rate-this.levels[index].sub;
                        }
                    }
                    return tax;
                },
                calcYearTax:function(monthIncome,yearIncome){
                    var nleft;
                    var ntax=0
                    if(monthIncome>=this.free){
                        for(nindex in this.levels){
                            nleft=yearIncome/12;
                            if(nleft>this.levels[nindex].low&&nleft<=this.levels[nindex].high){
                                ntax=yearIncome*this.levels[nindex].rate-this.levels[nindex].sub;
                                return ntax
                            }
                        }
                    }
                    else{                
                        for(index in this.levels){
                            yearIncome=yearIncome-(this.free-this.monthIncome)
                            nleft=yearIncome/12;
                            if(nleft>this.levels[index].low&&nleft<=this.levels[index].high){
                                ntax=yearIncome*levels[index].rate-levels[index].sub;
                                return ntax;
                            }
                        }
                    }
                }
            };
            function printf() {
                var monthIncome=document.getElementById("monthIncome").value;
                var yearIncome=document.getElementById("yearIncome").value;
                var mtax=table.calcMonthTax(monthIncome);
                var ytax=table.calcYearTax(monthIncome,yearIncome);
                var all=mtax*12+ytax;
                document.getElementById("mtax").value=mtax;
                document.getElementById("ytax").value=ytax;
                document.getElementById("all").value=all;
            }
        </script>
            <div class="box2 p2">
                 <input type="text" id="mtax" class="input"  placeholder="月税" readonly="readonly" >
            </div>    
            <div class="box2 p2">
                <input type="text" id="ytax" class="input"  placeholder="年税" readonly="readonly" >
            </div>
            <div class="box2 p2">
                <input type="text" id="all" class="input"  placeholder="全税" readonly="readonly" >
            </div>
        </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 12月31日
  • 已采纳回答 12月26日
  • 修改了问题 12月26日
  • 创建了问题 12月26日

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)