PDA

View Full Version : Problem with ie6


latemodern
09-13-2006, 05:00 PM
Hi,

I'm really new to JS and have just written my first function which calculates total, ex vat, and vat value in an invoice table using the price of the items and the quantity input by the user. This works fine in Firefox but nothing happens in ie6. Any ideas?

function calculateTotal(quantity, row) {
var trs = document.getElementsByTagName("tr");
var tr = trs.length
var tds = trs[row].getElementsByTagName("td");
td = tds.length;
for(var x=0; x < td; x++){
if(tds[x].getAttribute("class") == "price"){
var price = tds[x].firstChild.nodeValue;
var total = quantity * price;
}
if(tds[x].getAttribute("class") =="total"){
tds[x].firstChild.nodeValue = total.toFixed(2);
}
if(tds[x].getAttribute("class") == "exvat"){
var exvat = total/1.175;
tds[x].firstChild.nodeValue = exvat.toFixed(2);
}
if(tds[x].getAttribute("class") == "vat"){
var vat = (total- exvat);
tds[x].firstChild.nodeValue = vat.toFixed(2);
}
}
}

Fumigator
09-14-2006, 07:12 AM
There is a missing semi-colon on the 3rd line, that may be tripping up IE. Just a guess...

mrhoo
09-20-2006, 06:30 AM
getAttribute("class") doesn't return anything in IE,
try tds[x].className to keep everyone happy.