I posted this problem in the JavaScript forum, but based on the responses I got, I am suspicious the problem is with CF, not the JavaScript. What is supposed to happen is, the total should update dynamically as the user enters numbers. When I try it, the total is double what it should be. The alert window (which is in there for debugging purposes at this point) pops up twice. The first time, it shows the correct total, the second time, the total is doubled. This makes me think the script is executing twice. Here is the code that the person who responded to my post said worked for him, but it does not work for me. I even copied his code onto a blank document. Any ideas or suggestions greatly appreciated.
Calista :-X
Jedi Knight,
Champion of the Force
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Test Four</TITLE>
<SCRIPT>
<!--
function calculate(which)
{
MyTotal=parseInt(document.MyForm.TotalRegHours.value) + parseInt(which.value);
alert(MyTotal);
document.MyForm.TotalRegHours.value = MyTotal;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<CFPARAM NAME = TotalRegHours DEFAULT="0">
<CFSET RegHours = "0">
<CFOUTPUT>
<FORM ACTION="#CGI.SCRIPT_NAME#" METHOD="post" NAME="MyForm" ID="MyForm">
<CFLOOP INDEX="IdxOne" FROM="1" TO="5" STEP="1">
<INPUT TYPE="text" NAME="RegHours#IdxOne#" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONBLUR="calculate(this)"><BR>
</CFLOOP>
<BR>
<INPUT TYPE="text" NAME="TotalRegHours" CLASS="BlueTextBox" VALUE="0" READONLY SIZE="13">
</FORM>
</CFOUTPUT>
<BR>
</BODY>
</HTML>
Jedi Knight,
Champion of the Force