Hi guys i have some problem using checkbox.
I given the instruction to create a checkbox to calculate a book price
the problem is how to maka if user check 3 checkbox then the final price will discount by 15%.
here is my code:
<html>
<body>
<form action="" id="bookform" onsubmit="return false;">
<div class="book">
<input class ="checkbox1" type="checkbox" id="includerooster" name='includerooster' onclick="calculateTotal()" />
The Rooster Who Would Not Be Quiet!(PRICE :RM34.00)
<input class="checkbox1" type="checkbox" id="includeinstrumental" name='includeinstrumental' onclick="calculateTotal()" />
Instrumental: A Memoir of Madness, Medication and Music(PRICE :RM39.00)
<input class="checkbox1" type="checkbox" id="includechilbury" name='includechilbury' onclick="calculateTotal()" />
The Chilbury Ladies' Choir(PRICE :RM32.00)
</div>
<div id="totalPrice"></div>
</form>
<script>
function roosterPrice()
{
var roosterPrice=0;
var theForm = document.forms["bookform"];
var includeRooster= theForm.elements["includerooster"];
if(includeRooster.checked==true)
{
roosterPrice=34.00;
}
return roosterPrice;
}
function instrumentalPrice()
{
var instrumentalPrice=0;
var theForm = document.forms["bookform"];
var includeInstrumental = theForm.elements["includeinstrumental"];
if(includeinstrumental.checked==true){
instrumentalPrice=39.00;
}
return instrumentalPrice;
}
function chilburyPrice()
{
var chilburyPrice=0;
var theForm = document.forms["bookform"];
var includeChilbury = theForm.elements["includechilbury"];
if(includechilbury.checked==true){
chilburyPrice=32.00;
}
return chilburyPrice;
}
function calculateTotal()
{
var finalPrice = roosterPrice() + instrumentalPrice() + chilburyPrice();
if (finalPrice<100){
var postage = finalPrice + 10;
}else{
var postage = finalPrice;
}
var divobj = document.getElementById('totalPrice');
divobj.style.display='block';
divobj.innerHTML = "Total Price : RM"+finalPrice+".00"+"<br>"+"Postage : RM"+postage+".00";
}
</script>
</body>
</html>