Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > how to round off decimal point

Reply
Thread Tools

how to round off decimal point

 
 
arianne75 arianne75 is offline
Junior Member
Join Date: Jun 2007
Posts: 1
 
      06-08-2007
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/>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: round off to two decimal & return float ஆமாச்சு Python 1 03-30-2013 01:36 PM
round off to two decimal & return float ஆமாச்சு Python 2 03-30-2013 09:30 AM
How to truncate/round-off decimal numbers? Girish Sahani Python 15 12-17-2011 01:06 AM
decimal round off issue Shiping Zhang Perl Misc 17 09-28-2009 12:01 AM



Advertisments