This page here [url]www.heath-eu.com/TEST
The code, as you can see, just adds up the drop downs for each day, adds that number to the ‘already allocated’ number, and dumps the result back to the screen.
It works fine in firefox, but gives an error in IE.
Can anyone shed any light? The maths/ looping side of things are fine, it’s just the outputting that’s not working.
Here is the script:
[CODE]
<script type=”text/javascript”>
function altotal(thisday)
{
// Initialises variables
var iCount = 1;
var temphours = 0;
var currenthours = parseFloat(eval(“document.time.h” + thisday + “.value”));
// Counts through all the drop downs, adding the hours up
for (iCount = “1”; iCount < “16”; iCount++)
{
// Gets the value for the currently allocated hours
var thisdrop = eval(“document.getElementsByTagName(“select”)[” + iCount + “].name”);
thishours = parseFloat(eval(“document.time.” + thisdrop + “.value”));
// Adds up all the newly chosen hours if they’re for the correct day
today = thisdrop.substring(0,3)
if (thishours > “0” && thisday == today)
{
temphours = parseFloat(temphours) + parseFloat(thishours);
}
}
// Works out total hours by adding the above count to the number already saved
temphours = parseFloat(currenthours) + parseFloat(temphours);
// Puts the new hour total into the span
var daytoreplace = eval(“document.getElementById(“al” + thisday + “”)”);
replaceText(daytoreplace, temphours);
}
function replaceText(el, text)
{
if (el != null)
{
clearText(el);
var newNode = document.createTextNode(text);
el.appendChild(newNode);
}
}
function clearText(el)
{
if (el != null)
{
if (el.childNodes)
{
for (var i = 0; i < el.childNodes.length; i++)
{
var childNode = el.childNodes[i];
el.removeChild(childNode);
}
}
}
}
</script>
IE errors on this bit
[CODE]var newNode = document.createTextNode(text);
el.appendChild(newNode);
My knowledge of JS is minimal, I mainly code in PHP, so please, dumb it down a little ?
Thanks in advance,
James