...

View Full Version : Simple Javascript not working in firefox.



james13009
05-31-2012, 10:06 AM
Its been some while since I used javascript and even when I used to use it I was wasn't very good at it.

Can you tell me what is wrong with this script and how to get it working in firefox, there is more to the code but it manly these if statements repeating it self, I am think the code isn't valid or something.



function run() {
document.form1.RunnungT.value = "0"
var Total = 0;
document.all.testtext.innerHTML = "";

document.all.testtext.innerHTML = "<ul><b><u>Items Selected</u></b>";


if (document.form1.Thredbo.checked)
{
if (document.form1.J8.checked)
{
Total = Total + 469;
document.form1.RunnungT.value = Total;
document.all.testtext.innerHTML = document.all.testtext.innerHTML + "<li>Thredbo July 8th - 11th (Four days)</li>";
}
if (document.form1.J86.checked)
{
Total = Total + 669;
document.form1.RunnungT.value = Total;
document.all.testtext.innerHTML = document.all.testtext.innerHTML + "<li>Thredbo June 8th - 13th (Six days)</li>";
}

}

document.all.testtext.innerHTML = document.all.testtext.innerHTML + "</ul>";
}
</script>

felgall
05-31-2012, 10:28 AM
Get rid of the document.all calls that were for Internet Explorer 4 and replace them with document.getElementById() which works in all browsers that have been released in the last 10 years including IE5+, Firefox 0.1+ etc

vwphillips
05-31-2012, 10:36 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
</head>

<body>

<div id="testtext" ></div>
<script type="text/javascript">
/*<![CDATA[*/
document.getElementById('testtext').innerHTML='use document.getElementById';
/*]]>*/
</script>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum