I've got this script that someone else wrote and I've been modifying it to suit my needs. I was using Opera 7 to test the script and everything seemed normal. Then I tested it in other browsers and I started to get NaN instead of grandTotal. Why does Opera 7 display the grand total fine and every other engine doesn't? I haven't done much JavaScript before and from my reading of NaN, I still can't work out what's wrong with the script. The script is supposed to print an invoice with details passed from another html file via a form. Any help? Thanks.

<script language="JavaScript" type="text/JavaScript">
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;

orderData = "<table border=0 width='80%' style='border:1px solid #000' cellpadding='3'>";
orderData += "<tr><td style='border-bottom:2px solid #000'><strong>Description</strong></td><td style='border-bottom:2px solid #000'><strong>Cost in AUD</strong></td></tr>";
grandTotal = 0;
for (var i = 0; i < dataCount; i++)
{
valNum[i] = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData[i] = string;
else valData[i] = string.substring(0,string.indexOf("&"));
ampd = valData[i].indexOf("&");
pipe = valData[i].indexOf("-");
star = valData[i].indexOf("*");
line = valData[i].indexOf("$");
itemnum = string.substring(0,pipe);
itemdsc = string.substring(pipe+1,star);
itemcst = string.substring(star+1,line);
string = string.substring(ampd+1,string.length);

/* remove underscores */
itemdsc = itemdsc.replace(/_/g," ");
orderData += "<tr>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + itemdsc + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "cst value='$" + itemcst + "'>";
orderData += "<td style='border-bottom:2px solid #000'>" + itemdsc + "</td>";
orderData += "<td style='border-bottom:2px solid #000'>" + itemcst + "</td>";
orderData += "</tr>";
grandTotal += parseFloat(itemcst);
}
/* round decimal points to two points only */
var original=grandTotal;
var result=Math.round(original*100)/100
orderData += "<tr>";
orderData += "<td align=left><strong>Total</strong></td><td>" + result + "</td>";
orderData += "</tr>";
orderData += "<tr>";
orderData += "</tr>";
orderData += "</table>";

document.write(orderData);

}

// End -->
</script>