So, I have this code that’s adding the values of checked checkboxes together. The annoying part is that I can’t get the total to display as just normal text. I would then also like to use the total in a different function for calculating a percentage.
I’m a noob at javascript, so feel free to hack away at this…..
[CODE]
<!DOCTYPE html>
<html>
<body>
<form>
<input onclick=”clickCh(this)” type=”checkbox” name=”one” value=”10″> $10.00<br>
<input onclick=”clickCh(this)” type=”checkbox” name=”two” value=”12″> $12.00<br>
<br>
<input id=”total” type=”text” name=”total”>
</form>
<script language=”JavaScript” type=”text/javascript”>
var total = document.getElementById(“total”)
function clickCh(caller){
if(caller.checked){
add(caller)
} else {
subtract(caller)
}
}
function add(caller){ total.value = total.value*1 + caller.value*1}
function subtract(caller){ total.value = total.value*1 – caller.value*1}
</script>
Thanks!