Can any one help me with this script? It works perfect in Internet Explorer, but with FireFox it says $NaN
I dont know whats wrong.
<html>
<head>
<title>Form Total</title>
</head>
<form method=”post” action=”test” id=”theForm”>
<body>
<p>
<script type=”text/javascript”>
function total(frm) {
var tot=300;
for(var i=0; i<frm.elements.length; i++) {
if(frm.elements[i].type==”checkbox” || frm.elements[i].type==”radio”) {
if(frm.elements[i].checked) tot+=Number(frm.elements[i].value2);
}
}
document.getElementById(“totalDiv”).firstChild.data=”$”+tot;
}
</script>
</p>
<p>
</p>
<br>
<div><input type=”checkbox” name=”abx” value2=”50.00″ onclick=”total(this.form);”> abx +50.00</div>
<div><input type=”checkbox” name=”asss” value2=”30.00″ onclick=”total(this.form);”> asss+30.00</div>
<div><input type=”radio” name=”radio1″ value2=”-10.00″ onclick=”total(this.form);”>
wxyz -10.00</div>
<div><input type=”radio” name=”radio1″ value2=”20.00″ onclick=”total(this.form);”> asd +20.00</div>
<div><input type=”radio” name=”radio2″ value2=”11.00″ onclick=”total(this.form);”> wxyz +11.00</div>
<div><input name=”radio2″ type=”radio” onclick=”total(this.form);” value2=”12.00″ checked> asd +12.00</div>
<p> </p>
<p> </p>
<p>
<div id=”totalDiv”>Dynamic total requires Javascript</div>
</p>
<p> </p>
<p>
<script type=”text/javascript”>total(document.getElementById(“theForm”));</script>
<input type=”hidden” name=”merchant” value=”test”>
<input type=”hidden” name=”item_id” value=”16″>
<input type=”submit” name=”add” value=”Add to Cart”>
</p>
</body>
</html>