how to round off decimal point

Discussion in 'General Computer Support' started by arianne75, Jun 8, 2007.

  1. arianne75

    arianne75

    Joined:
    Jun 8, 2007
    Messages:
    1
    not a programmer but got this code to calculate rates. my problem is, i need to round off the amounts to just two numbers after the decimal. can someone please help me. below is the code for the calculator, please let me know what and where to insert the code to truncate the decimals.


    <script type="text/javascript">
    function calculate() {
    var b1 = parseFloat(document.getElementById("cons").value * 0.0024);
    var s1 = (1 * 22.00);
    var before = parseFloat(document.getElementById("rsch").value);
    var after = before + b1 +s1;
    document.getElementById("before").value = before;
    document.getElementById("after").value = after;
    document.getElementById("s1").value = s1;
    document.getElementById("b1").value = b1;
    }

    </script>
    Consumption Usage: <input type="text" id="cons"/><br/>
    Rate Schedule : <select id="rsch"><br/>
    <option value="7.46">R1</option>
    <option value="8.71">R2</option>
    <option value="13.67">R3</option>
    <option value="17.41">R4</option>
    <option value="31.09">R5</option>
    <option value="43.52">R6</option>
    <option value="80.82">R7</option>
    <option value="161.65">R8</option>
    <option value="192.73">R9</option>
    </select><br/>
    <button onclick="calculate();">Calculate</button><br/>

    Water Service Charge : <input type="text" id="before" disabled="true"/><br/>
    Water Charge : <input type="text" id="b1" disabled="true"/><br/>
    Sewer Residential Lifeline: <input type="text" id="s1" disabled="true"/><br/>
    Total Bill Amount : <input type="text" id="after" disabled="true"/><br/>
     
    arianne75, Jun 8, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alan

    Computer Goes Round and Round Checking

    Alan, Oct 1, 2004, in forum: Computer Support
    Replies:
    6
    Views:
    979
    Monroe Dowling
    Oct 8, 2004
  2. anOLDun

    bninary to decimal????

    anOLDun, Mar 9, 2006, in forum: Computer Support
    Replies:
    2
    Views:
    391
    fred-bloggs
    Mar 9, 2006
  3. anOLDun

    binary to decimal

    anOLDun, Mar 9, 2006, in forum: Computer Support
    Replies:
    11
    Views:
    879
    Leythos
    Mar 11, 2006
  4. DaGenester
    Replies:
    2
    Views:
    3,258
    Ed Rusi
    May 20, 2010
  5. Neal
    Replies:
    0
    Views:
    1,562
Loading...

Share This Page