javascript-还是if判断语句的问题

问题描述

还是if判断语句的问题

 /*
id :
    金额 input 利率 input1
 全额:
    离婚 lj 人格 lj1 执行 lj2 财产 lj3 支付令 lj4 延迟 lj5 逾期 lj6
 半额:
    离婚 lj7 人格 lj8 执行 lj9 财产lj10  支付令 lj11 延迟 lj12 逾期 lj13

*/

 $(document).ready(function () {
      //显示当前日期
    var d = new Date();
    var s2 = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
    $('#EntTime30').val(s2);

     //显示截止日期
    var d = new Date();
    var s1 = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
    $('#EntTime31').val(s1);

    //调用id 和id值改变后重新计算

    var input = parseFloat($("#input").val());
    var inprt1 = parseFloat($(" #input1").val());
    Costcalculator(input,input1);

    $("#input").change(function(){
        input = parseFloat($( this).val());

        Costcalculator(input,input1);
        });
    $("#input1").change(function(){
        input1 = parseFloat($(this).val());
        Costcalculator(input,input1);
        })
 });

 function Costcalculator(input,input1){
     input = parseFloat(input) || 0;
     input1 = parseFloat(input1) || 0;

     var al = 0;
     var sl = 0;
     var dl = 0;
     var el = 0;
     var fl = 0;
     var gl = 0;
     var hl = 0;
     var jl = 0;
     var kl = 0;
     var ll = 0;
     var ql = 0;
     var wl = 0;

        //受理费全额 半额计算
        if(input<=10000){ 

            al =  (input*input1/100)+50;

            sl = (input*input1/100)+50/2;

        }else if(input>10000 && input<=100000){

            al = [(input-10000)*2.5/100+50]*input1/100;

            sl = [(input-10000)*2.5/100+50]*input1/100/2;

        }else if(input>100000 && input<=200000){
            al = [(input-100000)*2/100+50]*input1/100;

            sl = [(input-100000)*2/100+50]*input1/100/2;

        }else if(input>200000 && input<=500000){
            al = [(input-200000)*1.5/100+50]*input1/100;

            sl = [(input-200000)*1.5/100+50]*input1/100/2;

        }else if(input>500000 && input<=1000000){
            al = [(input-500000)*1/100+50]*input1/100;

            sl = [(input-500000)*1/100+50]*input1/100/2;

        }else if(input>1000000 && input<=2000000){
            al = [(input-1000000)*0.9/100+50]*input1/100;

            sl = [(input-1000000)*0.9/100+50]*input1/100/2;

        }else if(input>2000000 && input<=5000000){
            al = [(input-2000000)*0.8/100+50]*input1/100;

            sl = [(input-2000000)*0.8/100+50]*input1/100/2;

        }else if(input>5000000 && input<=10000000){
            al = [(input-5000000)*0.7/100+50]*input1/100;

            sl = [(input-5000000)*0.7/100+50]*input1/100/2;

        }else if(input>10000000 && input<=20000000){
            al = [(input-10000000)*0.6/100+50]*input1/100;

            sl = [(input-10000000)*0.6/100+50]*input1/100/2;

        }else{
            al = [(input-20000000)*0.5/100+50]*input1/100;

            sl = [(input-20000000)*0.5/100+50]*input1/100/2;

        }

        //离婚计算
        if(input<=200000){

            dl = input*input1/100+100

            el = [(input*input1/100)+100]/2

        }else{
            dl = [(input-200000)*0.5/100+100]*input1/100;

            el = [(input-200000)*0.5/100+100]*input1/100/2;
            }

            var lj = 0;
            lj = al+dl;
            $("#lj").val(lj.toFixed(2));

            var lj7 = 0;
            lj7 = sl+el;
            $("#lj7").val(lj7.toFixed(2));

        //人格计算
        if(input<=50000){
            fl = input*input1/100+500;

            gl = [(input*input1/100)+500]/2;
        }else if(input>50000 && input<=100000){
            fl = [(input-50000)*1/100+500]*input1/100;

            gl = [(input-50000)*1/100+500]*input1/100/2;
        }else{
            fl = [(input-100000)*0.5/100+500]*input1/100;

            gl = [(input-100000)*0.5/100+500]*input1/100/2;
            }

            var lj1 = 0;
            lj1 = al+fl;
            $("#lj1").val(lj1.toFixed(2));

            var lj8 = 0;
            lj8 = sl+gl;
            $("#lj8").val(lj8.toFixed(2));
        //执行案件
        if(input<=10000){
            hl = input*input1/100+50;

            jl = [(input*input1/100)+50]/2;
        }else if(input>10000 && input<=500000){
            hl = [(input-10000)*1.5/100+50]*input1/100;

            jl = [(input-10000)*1.5/100+50]*input1/100/2;
        }else if(input>500000 && input<=5000000){
            hl = [(input-500000)*1/100+50]*input1/100;

            jl = [(input-500000)*1/100+50]*input1/100/2;
        }else if(input>5000000 && input<=10000000){
            hl = [(input-5000000)*0.5/100+50]*input1/100;

            jl = [(input-5000000)*0.5/100+50]*input1/100/2;
        }else{
            hl = [(input-10000000)*0.1/100+50]*input1/100;

            jl = [(input-10000000)*0.1/100+50]*input1/100/2;
            }

            var lj2 = 0;
            lj2 = al+hl;
            $("#lj2").val(lj2.toFixed(2));

            var lj9 = 0;
            lj9 = sl+jl;
            $("#lj9").val(lj9.toFixed(2));

        //财产计算
        if(input<=1000){
            kl = input*input1/100+30;

            ll = [(input*input1/100)+30]/2
        }else if(input>1000 && input<=100000){
            kl = [(input-1000)*1/100+30]*input1/100;

            ll = [(input-1000)*1/100+30]*input1/100/2;
        }else {
            kl = [(input-100000)*0.5/100+30]*input1/100;

            ll = [(input-100000)*0.5/100+30]*input1/100/2;
            }
            var lj3 = 0;
            lj3 = al+kl;
            $("#lj3").val(lj3.toFixed(2));

            var lj10 = 0;
            lj10 = sl+ll;
            $("#lj10").val(lj10.toFixed(2));

        //支付令计算
        if(input<=10000){
            ql = [(input*input1/100+50)]/3;

            wl = [(input*input1/100+50)/3]/2
        }else if(input>10000 && input<=100000){
            ql = [(input-10000)*2.5/100+50]/3*input1/100;

            wl = [(input-10000)*2.5/100+50]/3*input1/100/2;
        }else if(input>100000 && input<=200000){
            ql = [(input-100000)*2/100+50]/3*input1/100;

            wl = [(input-100000)*2/100+50]/3*input1/100/2;
        }else if(input>200000 && input<=500000){
            ql = [(input-200000)*1.5/100+50]/3*input1/100;

            wl = [(input-200000)*1.5/100+50]/3*input1/100/2;
        }else if(input>500000 && input<=1000000){
            ql = [(input-500000)*1/100+50]/3*input1/100;

            wl = [(input-500000)*1/100+50]/3*input1/100/2;
        }else if(input>1000000 && input<=2000000){
            ql = [(input-1000000)*0.9/100+50]/3*input1/100;

            wl = [(input-1000000)*0.9/100+50]/3*input1/100/2;
        }else if(input>2000000 && input<=5000000){
            ql = [(input-2000000)*0.8/100+50]/3*input1/100;

            wl = [(input-2000000)*0.8/100+50]/3*input1/100/2;
        }else if(input>5000000 && input<=10000000){
            ql = [(input-5000000)*0.7/100+50]/3*input1/100; 

            wl = [(input-5000000)*0.7/100+50]/3*input1/100/2;
        }else if(input<10000000 && input<=20000000){
            ql = [(input-10000000)*0.6/100+50]/3*input1/100;

            wl = [(input-10000000)*0.6/100+50]/3*input1/100/2;
        }else{
            ql = [(input-20000000)*0.5/100+50]/3*input1/100;

            wl = [(input-20000000)*0.5/100+50]/3*input1/100/2;
            }

            var lj4 = 0;
            lj4 = al+ql;
            $("#lj4").val(lj4.toFixed(2));

            var lj11 = 0;
            lj11 = sl+wl;
            $("#lj11").val(lj11.toFixed(2));
     }

页面在初始的时候 图片用红框圈住的地方会有值出来 我想让他不出来 我知道我赋值了 但是这个值必须用 现在要思考的是 怎么让这个值在页面初始的时候 没有他 但是在计算的时候还能计算 上面有我的js 请说明并帮我改正 说的仔细一点 谢谢

解决方案

没有他是什么意思?不显示还是不显示值?

不显示你设置容器.style.display='none'隐藏起来,如果是不显示值,你用一个自定义属性存储显示的值,如cv="111",然后就不要赋值就行了,计算的使用获取自定义属性值cv

 <input type="text" cv="111"/>

var cv=parseInt($('#xxx').attr('cv'))||0;
时间: 2024-08-01 09:06:56

javascript-还是if判断语句的问题的相关文章

JavaScript中的条件判断语句使用详解

这篇文章主要介绍了JavaScript中的条件判断语句使用详解,是JS入门学习中的基础知识,需要的朋友可以参考下 在写一个程序,可能有一种情况,当你需要采用一个路径出给定两个路径.所以,需要使用条件语句,让程序来做出正确的决策和执行正确的行动. JavaScript支持其用于执行根据不同的条件不同的操作条件语句.在这里,我们将解释if..else语句. JavaScript支持if..else语句的形式如下: if 语句 if...else 语句 if...else if... 语句. if 语

JavaScript中的条件判断语句使用详解_基础知识

 在写一个程序,可能有一种情况,当你需要采用一个路径出给定两个路径.所以,需要使用条件语句,让程序来做出正确的决策和执行正确的行动. JavaScript支持其用于执行根据不同的条件不同的操作条件语句.在这里,我们将解释if..else语句. JavaScript支持if..else语句的形式如下:     if 语句     if...else 语句     if...else if... 语句. if 语句: if语句是基本的控制语句,它允许JavaScript来作出决定,有条件地执行语句.

javascript-外部导入Javascript中的if语句无法执行判断

问题描述 外部导入Javascript中的if语句无法执行判断 解决方案 导入的js文件和内嵌js代码块不能共用一个script,要分别使用不同的script 解决方案二: 你找找看是不是你哪里有小毛病如果没有哪种方式执行了就用哪种:我在写javascript时也经常遇到这种问题. 解决方案三: 请问楼主,你的问题最后就是出现在括号这里吗

javascript if条件判断方法小结_javascript技巧

条件语句用于基于不同的条件来执行不同的动作. 条件语句 通常在写代码时,您总是需要为不同的决定来执行不同的动作.您可以在代码中使用条件语句来完成该任务. 在 JavaScript 中,我们可使用以下条件语句: •if 语句 - 只有当指定条件为 true 时,使用该语句来执行代码•if...else 语句 - 当条件为 true 时执行代码,当条件为 false 时执行其他代码•if...else if....else 语句 - 使用该语句来选择多个代码块之一来执行•switch 语句 - 使用

java、python、JavaScript以及jquery循环语句的区别_java

一.概述        python中循环语句有两种,while,for: JavaScript中循环语句有四种,while,do/while,for,for/in jQuery循环语句each 二.java 循环语句          a.while                 while 的语法为: while(条件语句){ 代码块 }           或者: while (条件语句) 代码; while的含义非常简单,只要条件语句为真,就一直执行后面的代码,为假就停止不做了.例如:

VBA判断语句

前面说了代码中三大元素中的变量与运算符,现在说一下语句中的判断语句,判断语句有下面几种形式: 1.If condition Then [statements][Else elsestatements]. 其中各部份的说明: 部分 描述 condition 必要参数.一个或多个具有下面两种类型的表达式: 数值表达式或字符串表达式,其运算结果为True或 False.如果 condition 为 Null,则 condition 会视为 False. TypeOf objectname Is obj

讲解JavaScript中for...in语句的使用方法

  这篇文章主要介绍了讲解JavaScript中for...in语句的使用方法,是JS入门学习中的基础知识,需要的朋友可以参考下 这里是JavaScript支持的另外一个循环.它被称为for...in循环.这个循环是用于循环一个对象的属性. 因为我们还没有讨论的对象,所以使用这一循环可能会感觉不太明白.但是,一旦你会对JavaScript对象了解后,那么会发现这个循环非常有用. 语法 ? 1 2 3 for (variablename in object){ statement or block

Javascript中For In语句用法实例

  本文实例讲述了Javascript中For In语句用法.分享给大家供大家参考.具体如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;

详解Python中的条件判断语句

  这篇文章主要介绍了Python中的条件判断语句,是Python入门中的基础知识,需要的朋友可以参考下 一个else语句可以使用if语句结合起来.如果在if语句中的条件表达式解析为0或false值,那么else语句包含代码执行. else语句是可选的声明,并if语句下面最多只有一个else语句. 语法: if ... else语句的语法是: ? 1 2 3 4 if expression: statement(s) else: statement(s) 例子: ? 1 2 3 4 5 6 7

解读Ruby当中的条件判断语句

  这篇文章主要介绍了详细解读Ruby当中的条件判断语句,if.else等逻辑判断语句是各门编程语言的基础,需要的朋友可以参考下 Ruby的提供有条件结构,常见在现代编程语言中.在这里,我们将解释Ruby所有条件语句和修饰符 Ruby if...else 语句: 语法: ? 1 2 3 4 5 6 7 if conditional [then] code... [elsif conditional [then] code...]... [else code...] end if 表达式用于条件执