In the following codes:
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browser
function chkHourlyRate()
{
if (isNaN(document.frmSRA.hourly_rate.value))
{
window.alert("You must enter a valid whole number or decimal number for rate."
frmSRA.hourly_rate.focus();
frmSRA.hourly_rate.select();
}
}
// Purpose: Calculate total pay
function calculatePay()
{
if (isNaN(document.frmSRA.total_hours.value))
{
window.alert("You must enter a valid whole number or decimal number for total hours."
frmSRA.total_hours.focus();
frmSRA.total_hours.select();
}
else
{
var rate = parseFloat(document.frmSRA.hourly_rate.value);
var hours = parseFloat(document.frmSRA.total_hours.value);
document.frmSRA.total_pay.value = Math.round(rate * hours * 100) / 100;
}
}
// Purpose: Open a new window and create/update the Compensation table.
function updateComp()
{
url = "/CommunityEd/Teachers/frmUpdateComp.cfm?ContextID=" + URL.ContextID + "&CourseID=" + URL.CourseID;
url += "&Rate=" + document.frmSRA.hourly_rate.value;
url += "&Hours=" + document.frmSRA.total_hours.value;
url += "&Compensation=" + document.frmSRA.total_pay.value;
url += "&Alternate=" + document.frmSRA.Alternate.value;
url += "&Additional=" + document.frmSRA.Additional.value;
sraWindow=window.open(url);}
// -->
</SCRIPT>
... in the body, I have a form called frmSRA. With the following code:
<FORM NAME="frmSRA">
...
<TR>
<TD><FONT SIZE=-1>Hourly Compensation:</FONT></TD>
<TD VALIGN="TOP">
$ <INPUT TYPE="TEXT" NAME="hourly_rate" MAXLENGTH=7 SIZE=4> x
<INPUT TYPE="TEXT" NAME="total_hours" MAXLENGTH=7 SIZE=4 onFocus="chkHourlyRate()"> HRS = $
<INPUT TYPE="TEXT" NAME="total_pay" MAXLENGTH=7 SIZE=5 onFocus="calculatePay()">
</TD>
</TR>
...
<INPUT TYPE="BUTTON" NAME="UpdateCompensation" VALUE="Update Hourly Compensation" onClick="updateComp(38235,4338)">
</FORM>
The problem is that if I take out the javascript function updateComp() then the program works well with no erros. But as soon as I put the javascript function updateComp() back in, then the program refuse to work properly. The javascript error occurs at the input text box called total_hours when the eventhandler onFocus="chkHourlyRate()" tries to execute.
The javascript error: Object expected. I can't figure out what object is it expecting and why this only happens when I leave the javascript function updateComp() in.
Can some help.
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browser
function chkHourlyRate()
{
if (isNaN(document.frmSRA.hourly_rate.value))
{
window.alert("You must enter a valid whole number or decimal number for rate."
frmSRA.hourly_rate.focus();
frmSRA.hourly_rate.select();
}
}
// Purpose: Calculate total pay
function calculatePay()
{
if (isNaN(document.frmSRA.total_hours.value))
{
window.alert("You must enter a valid whole number or decimal number for total hours."
frmSRA.total_hours.focus();
frmSRA.total_hours.select();
}
else
{
var rate = parseFloat(document.frmSRA.hourly_rate.value);
var hours = parseFloat(document.frmSRA.total_hours.value);
document.frmSRA.total_pay.value = Math.round(rate * hours * 100) / 100;
}
}
// Purpose: Open a new window and create/update the Compensation table.
function updateComp()
{
url = "/CommunityEd/Teachers/frmUpdateComp.cfm?ContextID=" + URL.ContextID + "&CourseID=" + URL.CourseID;
url += "&Rate=" + document.frmSRA.hourly_rate.value;
url += "&Hours=" + document.frmSRA.total_hours.value;
url += "&Compensation=" + document.frmSRA.total_pay.value;
url += "&Alternate=" + document.frmSRA.Alternate.value;
url += "&Additional=" + document.frmSRA.Additional.value;
sraWindow=window.open(url);}
// -->
</SCRIPT>
... in the body, I have a form called frmSRA. With the following code:
<FORM NAME="frmSRA">
...
<TR>
<TD><FONT SIZE=-1>Hourly Compensation:</FONT></TD>
<TD VALIGN="TOP">
$ <INPUT TYPE="TEXT" NAME="hourly_rate" MAXLENGTH=7 SIZE=4> x
<INPUT TYPE="TEXT" NAME="total_hours" MAXLENGTH=7 SIZE=4 onFocus="chkHourlyRate()"> HRS = $
<INPUT TYPE="TEXT" NAME="total_pay" MAXLENGTH=7 SIZE=5 onFocus="calculatePay()">
</TD>
</TR>
...
<INPUT TYPE="BUTTON" NAME="UpdateCompensation" VALUE="Update Hourly Compensation" onClick="updateComp(38235,4338)">
</FORM>
The problem is that if I take out the javascript function updateComp() then the program works well with no erros. But as soon as I put the javascript function updateComp() back in, then the program refuse to work properly. The javascript error occurs at the input text box called total_hours when the eventhandler onFocus="chkHourlyRate()" tries to execute.
The javascript error: Object expected. I can't figure out what object is it expecting and why this only happens when I leave the javascript function updateComp() in.
Can some help.