IE 8 error
Hi there.
I am a newbie in Javascript. Here is a little code that I want to use on my website (I've copied it from somewhere on internet). It adds the values of checkboxes and display them. It works fine in almost all browsers except IE7/8 (I've checked it is not working specifically in IE8). The error is: invalid argument on line 37 Char 1. Can anybody help me please?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>52573</title>
</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>
<script type="text/javascript">
var checkboxes = document.getElementById("checkboxes").getElementsByTagName("input");
for(var i = 0; i < checkboxes.length; i++)
{
checkboxes[i].onclick = tally;
}
function tally()
{
var total = 0;
for(var i = 0; i < checkboxes.length; i++)
{
if(checkboxes[i].checked)
{
total += parseInt(checkboxes[i].value);
}
}
document.getElementById("total").replaceChild( document.createTextNode(total), document.getElementById("total").firstChild);
}
tally();
</script>
</body>
</html>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks