Discounts: Example I (DOM)

$60.00 per dozen or $6.00 each.

Place your order

 

 

 

 

TOTAL

 

Code:

<script type="text/javascript">
function toCurrency(val,currency) {
return ((currency? currency:"") + (Math.round(val*100)+(val<0?-0.1:+0.1))/ 100).replace(/(.*\.\d\d)\d*/,'$1')
}
function calculatePrice(qty,price_single,price_dozen){
if(isNaN(qty)){document.getElementById("bar").innerHTML= "Enter quantity"; return;}
document.getElementById("bar").innerHTML=Math.floor(qty/12)+"dozen @ "+toCurrency(price_dozen,"$")
document.getElementById("foo").innerHTML=(qty%12)+" @ "+toCurrency(price_single,"$")
document.getElementById("A").innerHTML=toCurrency(price_dozen*Math.floor(qty/12))
document.getElementById("B").innerHTML=toCurrency(price_single*(qty%12))
document.getElementById("tot").innerHTML=toCurrency(price_dozen*Math.floor(qty/12)+ price_single*(qty%12),"$");
}
</script>