Thank you Kor - Your Code Works
I am really amazed by your professionalism. Your code also works perfectly. I have tested it for cross browser compatibility and it just works fine everywhere.
Thank you so very much.
Your forum is awesome.
God bless you.
Quote:
Originally Posted by
Kor
Maybe you should have a look on this approach:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function setEv(){
var check=document.getElementById('checkboxes').getElementsByTagName('input'), c, i=0;
while(c=check[i++]){c.onclick=addvalue;}
}
function addvalue(){
var t=0;
var check=this.parentNode.getElementsByTagName('input'), c, i=0;
while(c=check[i++]){c.checked?t+=Number(c.value):null}
document.getElementById('total').innerHTML=t;
}
onload = setEv;
</script>
</head>
<body>
<form>
<fieldset id="checkboxes">
<input type="checkbox" value="1">
<input type="checkbox" value="2">
<input type="checkbox" value="4">
<input type="checkbox" value="8">
<input type="checkbox" value="16">
<input type="checkbox" value="32">
</fieldset>
</form>
<p>The total is: <span id="total"></span></p>
</body>
</html>