473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

onSubmit="A whole bunch of headaches"

Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">

Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

Jul 23 '05 #1
12 1616
micahl0180 wrote:
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">

Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

I'm a newbie of six months and had set myself a goal of answering this
to test myself... and I got it (so I suppose we're both happy about that).
<script language="JavaScript" type="text/javscript">
You have said javscript - note, you're missing the second 'a' in
javascript thus, the tag should read:
<script language="JavaScript" type="text/javascript">

Simple but don't beat yourself over the head about it... It took me a
few minutes before I picked it up...

best of luck
randelld
Jul 23 '05 #2
In article <MC0fc.17394$U83.7506@fed1read03>, micahl0180
<mi********@cox.net> wrote:
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">

Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

type="text/javscript" is invalid
It should be type="text/javascript"

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #3
Gentleman,

I have to thank you not only for finding the error, but for your timely
response as well. You are both truely incredible. Thank you again.
"micahl0180" <mi********@cox.net> wrote in message
news:MC0fc.17394$U83.7506@fed1read03...
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31: <form action="" method="post" name="payroll" onSubmit="earnings()">

Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

Jul 23 '05 #4
In article <MC0fc.17394$U83.7506@fed1read03>,
"micahl0180" <mi********@cox.net> wrote:
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">

Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<script language="JavaScript" type="text/javscript">


You need to change javscript to javascript.

Here is fixed up page. See where I put in alerts to see what wasn't
going on in the code.

May not be working for over 40 hours.
Robert

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<SCRIPT type="text/javascript">

function diffEmail()
{
alert("in diffEmail()");
}
// Begin function to calcualte and display weekly earnings
alert("in head section");
function calcEarnings() {
var hrs = document.payroll.hours.value;
var hrly = document.payroll.rate.value;
var overtime = 0;
var check = 0;
var hrlypay = 0;
var overtimepay = 0;
parseFloat(hrs);
parseFloat(hrly);
if (hrs > 40) {
overtime = hrs - 40;
hrs = 40;
}
hrylpay = hrs * hrly;
overtimepay = overtime * hrly;
check = hrlypay + overtimepay;
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay);
}
// End function to calculate and display weekly earning
</script>

</head>
<body>
<form action="" method="post" name="payroll"
onSubmit="alert('submit');calcEarnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>
Jul 23 '05 #5
Dennis M. Marks wrote:
<mi********@cox.net> wrote:
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">
Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.

TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?&nbsp&nbsp</b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?&nbsp&nbsp</b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">&nbsp&nbsp
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>

type="text/javscript" is invalid
It should be type="text/javascript"


Also you spelled hrlypay inconsistently:

hrylpay = hrs * hrly
check = hrlypay

Try this:

function earnings() {
var totalhrs = +document.payroll.hours.value;
var hrly = +document.payroll.rate.value;
var overtime = +0;
hrs=totalhrs;
if (hrs>40) {
overtime=hrs-40;
hrs = 40;
}
var hrlypay = hrs * hrly; //pay at normal rate
var overtimepay = overtime * hrly * 1.5; //pay at overtime rate
var check = hrlypay + overtimepay;
var result='Total Hours Worked: ' + totalhrs;
result += '\nHours at Regular Pay: ' + hrs;
result += '\nHours at Overtime Pay: ' + overtime;
result += '\nRegular Pay Rate: ' + hrly;
result += '\nOvertime Pay Rate: ' + hrly * 1.5;
result += '\nPay at Regular Rate: ' + hrlypay;
result += '\nPay at Overtime Rate: ' + overtimepay;
result += '\nTotal Pay: ' + check;
alert(result);
}

MIke

Jul 23 '05 #6
In article <w81fc.109534$Ig.1719@pd7tw2no>,
Reply Via Newsgroup <re****************@please.com> wrote:

Simple but don't beat yourself over the head about it... It took me a
few minutes before I picked it up...

best of luck
randelld


It took me a while to find it too.

My coding style is to always copy the script tags.

I wonder why you do not get some error message?

Robert
Jul 23 '05 #7
Robert wrote:
<snip>
I wonder why you do not get some error message?


Because the browser's reaction to being presented with script tags
specifying a script language that it doesn't understand/implement is not
to attempt to execute it (it cannot decide that text/javscript isn't a
real script language, because it might be). And a script that is never
run cannot error.

Richard.
Jul 23 '05 #8
Richard Cornford wrote:
Robert wrote:
<snip>
I wonder why you do not get some error message?

Because the browser's reaction to being presented with script tags
specifying a script language that it doesn't understand/implement is not
to attempt to execute it (it cannot decide that text/javscript isn't a
real script language, because it might be). And a script that is never
run cannot error.

Richard.


But it did error - One gets "Object Expected"...

Is it a 'feature' of javascript?

randelld
Jul 23 '05 #9
Reply Via Newsgroup wrote:
<snip>
But it did error - One gets "Object Expected"...

Is it a 'feature' of javascript?


The event handling attribute function errored because it could not find
the function that it was trying to call (because it had been specified
in an unknown scripting language and so not instantiated). The event
handling attribute code is not influenced by the type attribute
assignments of any script elements (except on IE, where they default to
the language of the first script element encountered, or JScript if
there is no separate script element, though the W3C have a different
idea about how the language for intrinsic events should be defaulted).

Richard.
Jul 23 '05 #10
Because the browser's reaction to being presented with script tags
specifying a script language that it doesn't understand/implement is not
to attempt to execute it (it cannot decide that text/javscript isn't a
real script language, because it might be).


Couldn't is say it doesn't have an interpreter or plugin for javscript?

Robert
Jul 23 '05 #11
Robert wrote:
Because the browser's reaction to being presented with script tags
specifying a script language that it doesn't understand/implement is
not to attempt to execute it (it cannot decide that text/javscript
isn't a real script language, because it might be).


Couldn't is say it doesn't have an interpreter or plugin for
javscript?


Would you really want to be told every time you loaded a page that
contained any VBScript? Would such a warning provide any value to the
bulk of browser users?

Scripting is supposed to be an optional extra, and possible in any
language (though nobody seems interested in implementing any language
but ECMAScirpt, except Microsoft) so quietly ignoring anything that
cannot be used is the logical (and specified) reaction.

Richard.
Jul 23 '05 #12
On Thu, 15 Apr 2004 02:08:07 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote:
though the W3C have a different
idea about how the language for intrinsic events should be defaulted).


but it didn't have 2 independant implementations when it went to REC,
is badly specified*, so I think we should ignore it, avoiding all
intrinsic events would be better than using that awful hack.

Jim.

* Meaning of course that it should never have got to REC but the W3
used to ignore their own process documents, they're getting much
better, but keep an eye on them - the HTML WG are also the worst IMO.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
3
by: Simon Wigzell | last post by:
My client has many forms on his Business website. They all use the "onsubmit" verification method e.g. <form ......... onsubmit="return FormValidator(this);"> <script> function...
2
by: gachris | last post by:
I have a return false as part of my if statement and my form is still submitting. Here is the simple example. Any suggestions? if(msg != ""){ alert(msg); return false; }else{ //submit the...
5
by: http://links.i6networks.com | last post by:
I want to force the users to click submit to submit the forms. How do I disable "Enter Key" which will submit the form automatically when they entered the data in text field then pressed "enter key"
2
by: SmittyBroham | last post by:
Hello, I have a function that loops through 2 select lists and records the values of any hi-lighted options a user would have selected. It then sets 2 corresponding "hidden" form elements to the...
0
by: Joeyej | last post by:
Hi - I'm trying to move/use a web form (containing some javascript field checks) previously hosted on a Windows 2000 server. However, the FORM METHOD="post..." command in the form (shown below)...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
5
by: Nathan Sokalski | last post by:
I have an ASP.NET application which is giving the following JavaScript error: 'theForm' is undefined However, when I do a View Source one of the <scriptelements is as follows: <script...
13
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.