# Newb needs help rounding

**URL:** <https://forum.kirupa.com/t/newb-needs-help-rounding/329095>\
**Category:** Uncategorized\
**Created:** [July 19, 2012, 8:00pm UTC](https://forum.kirupa.com/t/newb-needs-help-rounding/329095 "2012-07-19T20:00:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian2112](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@brian2112](https://forum.kirupa.com/u/brian2112)\
**Post date:** [July 19, 2012, 8:00pm UTC](https://forum.kirupa.com/t/newb-needs-help-rounding/329095/1 "2012-07-19T20:00:18Z")

</div>

I have a web site which calculates a discount based on selection of a checkbox, I would like the output into “total” to be rounded to zero (0) decimal places. I have tried a couple of thing and they fail to write to “total”.  
Thank you for the help in advance,

Brian

clear\_form is clearing form of any previous entries  
discountValue is a var dependent on if checkbox is checked or unchecked  
k is var which is the before discount price  
“discount” is input type=“text”  
“total” is input type=“text”  
fillInButton() is a function to send the total to paypal

function discountAmount()  
{  
clear\_form\_elements(document.getElementById(“section\_4”));  
number2 = k \* discountValue;  
document.getElementById(“discount”).value = “$” + “-” + number2;  
p = k - number2  
document.getElementById(“total”).value = “$” + p;  
fillInButton();  
}
