Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In the following codes: <SCRIPT

Status
Not open for further replies.

khue

Programmer
Mar 6, 2001
112
US
In the following codes:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Hide from old browser

function chkHourlyRate()
{
if (isNaN(document.frmSRA.hourly_rate.value))
{
window.alert(&quot;You must enter a valid whole number or decimal number for rate.&quot;)
frmSRA.hourly_rate.focus();
frmSRA.hourly_rate.select();
}
}

// Purpose: Calculate total pay
function calculatePay()
{
if (isNaN(document.frmSRA.total_hours.value))
{
window.alert(&quot;You must enter a valid whole number or decimal number for total hours.&quot;)
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 = &quot;/CommunityEd/Teachers/frmUpdateComp.cfm?ContextID=&quot; + URL.ContextID + &quot;&CourseID=&quot; + URL.CourseID;
url += &quot;&Rate=&quot; + document.frmSRA.hourly_rate.value;
url += &quot;&Hours=&quot; + document.frmSRA.total_hours.value;
url += &quot;&Compensation=&quot; + document.frmSRA.total_pay.value;
url += &quot;&Alternate=&quot; + document.frmSRA.Alternate.value;
url += &quot;&Additional=&quot; + document.frmSRA.Additional.value;

sraWindow=window.open(url);}
// -->
</SCRIPT>

... in the body, I have a form called frmSRA. With the following code:

<FORM NAME=&quot;frmSRA&quot;>

...

<TR>
<TD><FONT SIZE=-1>Hourly Compensation:</FONT></TD>
<TD VALIGN=&quot;TOP&quot;>
$ <INPUT TYPE=&quot;TEXT&quot; NAME=&quot;hourly_rate&quot; MAXLENGTH=7 SIZE=4> x
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;total_hours&quot; MAXLENGTH=7 SIZE=4 onFocus=&quot;chkHourlyRate()&quot;> HRS = $
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;total_pay&quot; MAXLENGTH=7 SIZE=5 onFocus=&quot;calculatePay()&quot;>
</TD>
</TR>

...

<INPUT TYPE=&quot;BUTTON&quot; NAME=&quot;UpdateCompensation&quot; VALUE=&quot;Update Hourly Compensation&quot; onClick=&quot;updateComp(38235,4338)&quot;>
</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=&quot;chkHourlyRate()&quot; 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.
 
First of all the call of updateComp from the button tries to pass two numbers and the function doesn't have two objects in the brackets on declaration. Plus there is a trailing &quot;\&quot; after the semi-colon &quot;SraWindow = window.open(url);\&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top