Javascript为什么var s = x + t == 9.5.14.6而不是24.1

时间:2017-06-26 07:44:45

标签: javascript operators

我有以下代码,不明白为什么 var s = x + t == 9.5.14.6而不是24.1

以前的运算符基本计算似乎有效,但上面似乎没有。

一如既往,非常感谢您的指导。

<div id="wrap">
    <form action="" id="ratesform" onsubmit="return false;">

    <div>
        <div class="cont_order">
           <fieldset>
            <legend>Temp Rates Calculator!</legend>
            <label >Pricing Inclusive of Pension</label>

<!//Form Data>  

<p id="inputform" 

<form id="ratesform" action="/action_page.php">

            Pay Rate:
            <br>
            <input type="text" name="payrateph">
            <br>

            SSP :
            <br>
            <input type="text" name="ssp">
            <br>

            Agency Margin (GBP):
            <br>
            <input type="text" name="agencymarginpound">
            <br>

            Average Weekly Hours:
            <br>
            <input type="text" name="averageweeklyhours">
            <br>





            <br>
            <button onclick="myFunction()">Submit Query</button>

</form> 

            <p id="payrateph"           ></p>
            <p id="ssp"                 ></p>
            <p id="agencymarginpound"   ></p>
            <p id="averageweeklyhours"  ></p>               
            <p id="varv"                ></p>
            <p id="varu"                ></p>
            <p id="vart"                ></p>
            <p id="vars"                ></p>
            <p id="varr"                ></p>
            <p id="varq"                ></p>
            <p id="varp"                ></p>
            <p id="varo"                ></p>
            <p id="varn"                ></p>
            <p id="varm"                ></p>

<!//Start of Java Script>   

<script>

//Declaring variables>
var x = document.getElementById('ratesform').elements[1].value;
number = document.getElementById('payrateph').innerHTML;

var y = document.getElementById("ratesform").elements[2].value;
number = document.getElementById("ssp").innerHTML   

var z = document.getElementById("ratesform").elements[3].value;
document.getElementById("agencymarginpound").innerHTML  

var w = document.getElementById("ratesform").elements[4].value;
document.getElementById("averageweeklyhours").innerHTML


var v = (x * w);
var u = (v * 0.1207);
var t = (u / w);
var s = x+t;
var r = (1);
var q = (1);
var p = (1);
var o = (1);
var n = (1);
var m = (1);


//posting variables to html body>


function myFunction()
{

document.getElementById("ratesform").elements[1].value;
number = document.getElementById("payrateph").innerHTML = "Hourly Pay     Rate:  " + x;

document.getElementById("ratesform").elements[2].value;
number = document.getElementById("ssp").innerHTML = "Sick Pay:   " + y;

document.getElementById("ratesform").elements[3].value;
number = document.getElementById("agencymarginpound").innerHTML = "Agency Margin:   " + z;

document.getElementById("ratesform").elements[4].value;
number = document.getElementById("averageweeklyhours").innerHTML = "Average Weekly Hours:   " + w;

number = document.getElementById("varv").innerHTML =
"Total Weekly Pay: " + v;

number = document.getElementById("varu").innerHTML =
"Working Time Directive @ 12.07%: " + u;

number = document.getElementById("vart").innerHTML =
"Working Time Directive per hour: " + t;

number = document.getElementById("vars").innerHTML =
"Total pay plus WTD: " + s;

number = document.getElementById("varr").innerHTML =
"Total pay plus pension: " + r;

number = document.getElementById("varq").innerHTML =
"Total NI Including Freepay: " + q;

number = document.getElementById("varp").innerHTML =
"Total NI Including Freepay: " + p;

number = document.getElementById("varo").innerHTML =
"NI per hour: " + o;

number = document.getElementById("varn").innerHTML =
"Total pay cost: " + n;

number = document.getElementById("varm").innerHTML =
"Apprenticeship Levy: " + m;

}

0 个答案:

没有答案