Here's what I'm trying to do. I want to present a series of textboxes for the user to enter numbers. I want the total to update dynamically as each number is entered. What I have here does that, but it's rather messy. I know how to display the textboxes using a loop, but I can't get the script to work with it. Any suggestions?
Thanks! Calista :-X
Jedi Knight,
Champion of the Force
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<SCRIPT>
<!--
function calculate(which)
{
document.MyForm.TotalRegHours.value =
(document.MyForm.TotalRegHours.value - 0)
+ (document.MyForm.RegHoursOne.value - 0)
+ (document.MyForm.RegHoursTwo.value - 0)
+ (document.MyForm.RegHoursThree.value - 0)
+ (document.MyForm.RegHoursFour.value - 0)
+ (document.MyForm.RegHoursFive.value - 0);
return;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<CFPARAM NAME="TotalRegHours" DEFAULT="0">
<CFSET RegHours = "0">
<CFOUTPUT>
<FORM ACTION="#CGI.SCRIPT_NAME#" METHOD="post" NAME="MyForm" ID="MyForm">
<INPUT TYPE="text" NAME="RegHoursOne" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONKEYUP="calculate(this)"><BR>
<INPUT TYPE="text" NAME="RegHoursTwo" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONKEYUP="calculate(this)"><BR>
<INPUT TYPE="text" NAME="RegHoursThree" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONKEYUP="calculate(this)"><BR>
<INPUT TYPE="text" NAME="RegHoursFour" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONKEYUP="calculate(this)"><BR>
<INPUT TYPE="text" NAME="RegHoursFive" CLASS="WhiteTextBox" VALUE="#RegHours#" SIZE="13" ONKEYUP="calculate(this)"><BR><BR>
<INPUT TYPE="text" NAME="TotalRegHours" CLASS="BlueTextBox" VALUE="#TotalRegHours#" READONLY SIZE="13">
</FORM>
</CFOUTPUT>
<BR><BR>
</BODY>
</HTML>
Jedi Knight,
Champion of the Force