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 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)