
June 26th, 2007, 11:34 AM
|
|
Registered User
|
|
Join Date: Jun 2007
Posts: 1
Time spent in forums: 1 h 7 m 18 sec
Reputation Power: 0
|
|
|
Need Help Debugging Script/Error in Script - Help a rookie troubleshoot his first javascript program
Hi,
I am computer literate, but a javascript rookie. I have a simple script I am trying to use to automate a registration form. It works just fine inside of MSfrontpage preview, but I get an error when tried in IE. The error occurs when i select any of the checkboxes on the form. The error is as follows:
Line: 25
Char: 9
Error: 'document.orderform.Item1' is null or not an object Code:0
The script is as follows: (I copied part from a free javascript page on the www)
Code:
<script type="text/JavaScript"><!--
var Cost, Grand_Total;
function tally()
{
Cost = 0;
if (document.orderform.Item1.checked) { Cost = Cost + 1525.00;}
if (document.orderform.Item2.checked) { Cost = Cost + 650.00;}
if (document.orderform.Item3.checked) { Cost = Cost + 120.00;}
if (document.orderform.Item4.checked) { Cost = Cost + 120.00;}
if (document.orderform.Item5.checked) { Cost = Cost + 195.00;}
if (document.orderform.Item6.checked) { Cost = Cost + 195.00;}
if (document.orderform.Item7.checked) { Cost = Cost + 120.00;}
if (document.orderform.Item8.checked) { Cost = Cost + 120.00;}
Cost = dollar(Cost);
Grand_Total = parseFloat(Cost);
Grand_Total = dollar(Grand_Total);
document.orderform.Total.value = "$" + Cost;
document.orderform.GrandTotal.value = "$" + Grand_Total;
}
function dollar (amount)
{
amount = parseInt(amount * 100);
amount = parseFloat(amount/100);
if (((amount) == Math.floor(amount)) && ((amount - Math.floor (amount)) == 0))
{
amount = amount + ".00"
return amount;
}
if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
{
amount = amount + "0";
return amount;
}
if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
{
amount = amount;
return amount;
}
return amount;
}
//--></script>
I can post the complete HTML code if needed to help troubleshoot. Please help if you can! Thanks!
|