Mam pproblem, chce zeby moj skrypt zaipisywal tylko do dwoch liczb po pprrzecinku wiem ze powienieniem uzyc toFixed ale po moich probach nie dziala nic

takze mam problem z wyswietlaniem total jak uzylem parseFloat() zamiast parseInt() moglby ktos na to spojrzec i powiedziec mi gdzie mam uzyc toFixed i zeby poprawnie wyswietlalo mi wynik total
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
var nameOfBook
= Array(), priceOfBook
= Array(), index
= 1
, total
= 0;
function addBook()
{
nameOfBook[index] = document.getElementById('name').value;
//we changing type of variable from string to int
priceOfBook[index] = parseFloat(document.getElementById('price').value);
document.getElementById('name').value = '';
document.getElementById('price').value = '';
index++;
}
//we get data fromm form and put in array
function displayBooks()
{
for(var i = 1; i < index; i++)
{
document.write(i+". "+nameOfBook[i]+" - "+priceOfBook[i]+"<br>");
total = total+priceOfBook[i];
}
document.write("<br><b>Total: </b>"+total);
}
// print out list of books with price we added before and total price
</script>
</head>
<body>
<div id="books">
<label>Enter name of book: </label><input id="name" type="text">
<br><br><label>Enter price of book: </label><input id="price" type="text">
<br><button onClick="addBook()">Add</button>
</div>
<br><br>
<button onClick="displayBooks()">Calculate</button>
</body>
</html>
udalo mi sie juz zrobic zeby wyswietlalo dwa miejsca po przecinku ale nie dziala mi dalej podliczanie total, moze mi ktos pomoc

? ?!
ok, udalo mi sie juz zapisysywac liczby w ulamkach dziesietnych i wyswietla tylko do dwoch miejsc po przeciknku ale dalej nie dziala mi podliczanie total
<!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1--><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
var nameOfBook
= Array(), priceOfBook
= Array(), index
= 1
, total
= 0;
function addBook()
{
nameOfBook[index] = document.getElementById('name').value;
//we changing type of variable from string to int
priceOfBook[index] = parseFloat(document.getElementById('price').value);
document.getElementById('name').value = '';
document.getElementById('price').value = '';
index++;
}
//we get data fromm form and put in array
function displayBooks()
{
for(var i = 1; i < index; i++)
{
document.write(i+". "+nameOfBook[i]+" - "+priceOfBook[i].toFixed(2)+"<br>");
total = total+priceOfBook[i];
}
document.write("<br><b>Total: </b>"+total);
}
// print out list of books with price we added before and total price
</script>
</head>
<body>
<div id="books">
<label>Enter name of book: </label><input id="name" type="text">
<br><br><label>Enter price of book: </label><input id="price" type="text">
<br><button onClick="addBook()">Add</button>
</div>
<br><br>
<button onClick="displayBooks()">Calculate</button>
</body>
</html><!--c2--></div><!--ec2-->