473,671 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

object expected error

Hi, I've been working on this for a while now and I can't seem to find
out what is wrong with my code. I have 2 files one c3common.js which
only contains javascript functions for my main html page and my main
html page which is test.html. They are of course part of a much bigger
system of files but i have tracked down the problem to that reduced
part of the code. The page loads perfectly fine however when i click
search i get the error line:37 object expected, which is the line of
the <form name=...... onSubmit="retur n validate(this); "> The code
basically just takes the data entered in name, email and phone number
and validates them with premade functions. now i know theres nothing
wrong with the functions in c3common.js because when i cut and paste
them into the html page in the script part everything starts working
perfectly but as soon as i move them into another .js file and link the
html page with the scr="c3common.j s" piece of code i get the error. Oh
and before you ask the files are in the same directory so thats not the
problem. Thanks a lot for your time guys.

here it goes:

test.html =

<html>
<head>
<title>ShowEmpl oyees (using JSTL)</title>

<script src="c3common.j s" type="text/javascript"
language="JavaS cript">

function validate(form)
{

window.alert("C HECK!"); //this never even gets shown at all

var check =1;

if(CheckName(fo rm.name.value) == false)
{
window.alert("w rong name");
check =0;
}
if(CheckEmail(f orm.email.value ) == false)
{
window.alert("w rong email");
check =0;
}
if(CheckPhoneNu mber(form.telep hone.value) == false)
{
window.alert("w rong telephone");
check =0;
}

return check;
}
</script>
</head>

<body>

<form name="search" method="POST" onsubmit="retur n
validate(this); ">
<h1>Searching Employees Database</h1>

<table>
<tr>
<td>Name</td> <td><input type="text" name="name" value=""/> </td>
</tr>
<tr>
<td>E-mail Address</td> <td><input type="text" name="email"
value=""/> </td>
</tr>
<tr>
<td>Phone number</td> <td><input type="text" name="telephone "
value=""/> </td>
</tr>
<tr>
<td><input type="hidden" name="action" value="showEmpl oyees"/>
</td>
<td><input type="hidden" name="page" value="0" /> </td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Search"/> </td>
<td><input type="reset" value="Resets all fields"/> </td>
</tr>
</table>
</form>
</body>
</html>

Feb 27 '06 #1
39 13413
VK

eruan...@hotmai l.com wrote:
<html>
<head>
<title>ShowEmpl oyees (using JSTL)</title>

<script src="c3common.j s" type="text/javascript"
language="JavaS cript">

function validate(form)


You cannot use one <script> tag for both .js file and inline code:-
inline code is being ignored in this case.

Change to:

<script src="c3common.j s" type="text/javascript"></script>
<script type="text/javascript">
// inline code
</script>

As I see this error over and over in different places, I presume that
some "reputable" source claims that it's possible. If it's a wiki I
would appreciate to be pointed out so I could correct the article.

P.S. It is generally a bad idea to name you form field "name" - it may
lead to some funny addressing issues.
"customer", "user", "requester" etc. are much better.

Feb 27 '06 #2
ohh thank you soo much, for some reason i has tried that before but
then i had made some changes to the code that might have messed it up,
works perfectly now thx.

Feb 27 '06 #3
VK wrote:
eruan...@hotmai l.com wrote:
<html>
<head>
<title>ShowEmpl oyees (using JSTL)</title>

<script src="c3common.j s" type="text/javascript"
language="JavaS cript">

function validate(form)
You cannot use one <script> tag for both .js file and
inline code:-


You cannot use one SCRIPT _tag_ for anything as HTML requires two script
tags to define one SCRIPT element (opening and closing tags are not
optional).

But you can use one SCRIPT element to import a file and simultaneously
define script within that element. It isn't a good idea to do so but it
is a reasonably commonly implemented facility; see the FAQ.
inline code is being ignored in this case.
That would depend upon the browser and factors beyond your current
understanding.
Change to:

<script src="c3common.j s" type="text/javascript"></script>
<script type="text/javascript">
// inline code
</script>
That is 4 _tags_ defining two _elements_. Acquiring a basic
understanding of HTML would be a good idea prior to attempting to give
advice on the subject. The distinction between an HTML tag and an
element being pretty basic.
As I see this error over and over in different places, I
presume that some "reputable" source claims that it's possible. <snip>

You see something you don't understand and assume that it is an error,
but the one does not follow from the other, especially as you don't
actually understand the code you write yourself (even if you are not
necessarily aware of that yourself).
P.S. It is generally a bad idea to name you form field "name"
- it may lead to some funny addressing issues.
"customer", "user", "requester" etc. are much better.


Name or NAME would do just as well, as javascript is case sensitive.

Richard.
Mar 1 '06 #4
Richard Cornford wrote:
VK wrote:
eruan...@hotmai l.com wrote:
<html>
<head>
<title>ShowEmpl oyees (using JSTL)</title>

<script src="c3common.j s" type="text/javascript"
language="JavaS cript">

function validate(form)
You cannot use one <script> tag for both .js file and
inline code:-


You cannot use one SCRIPT _tag_ for anything as HTML requires two script
tags to define one SCRIPT element (opening and closing tags are not
optional).


True.
But you can use one SCRIPT element to import a file and simultaneously
define script within that element.
No, you cannot. It is specified and implemented that

,-[HTML 4.01, 18.2.1 The SCRIPT element]
|
| [...] If the `src' has a URI value, user agents must ignore
| the element's contents and retrieve the script via the URI.

See below.

(There is also a common misconception among some people here regarding the
`charset' attribute [but the FAQ is clear and correct about it, the misuse
of the "tag" term aside] that is addressed by the next sentence of the
spec:

"Note that the `charset' attribute refers to the character encoding of the
script designated by the `src' attribute; it does not concern the content
of the SCRIPT element.")
It isn't a good idea to do so
True.
but it is a reasonably commonly implemented facility;
It is not in Netscape 4.8, Mozilla 1.7.12, Firefox 1.5.0.1, Opera 8.52, and
KHTML 3.5.1:

<URL:http://pointedears.de/scripts/test/include>

Netscape 4.8 even navigates to the Error 404 document if a script resource
is specified that does not exist. (Interestingly, KJS 3.5.1 does not allow
for augmentation of the Object constructor.)
see the FAQ.


The FAQ has to be corrected in that regard.
PointedEars
Mar 1 '06 #5
Thomas 'PointedEars' Lahn wrote:
<URL:http://pointedears.de/scripts/test/include>

[...] (Interestingly, KJS 3.5.1 does not allow for augmentation of the
Object constructor.)


Ignore that, it does. It is just that the remote version of object.js still
used FunctionExpress ions in Object literals which are not supported by KJS
as yet. Therefore the included script could not be compiled, and the
Object constructor was not augmented. If you use only references to those
Function objects instead, everything is fine.
PointedEars
Mar 12 '06 #6
Thomas 'Ingrid' Lahn wrote:
Thomas 'PointedEars' Lahn wrote:
<URL:http://pointedears.de/scripts/test/include>

[...] (Interestingly, KJS 3.5.1 does not allow for augmentation of the
Object constructor.)


Ignore that, it does. It is just that the remote version of object.js
still used FunctionExpress ions in Object literals which are not supported
by KJS as yet. Therefore the included script could not be compiled, and
the Object constructor was not augmented. If you use only references to
those Function objects instead, everything is fine.


It gets even more strange: the above statement is not generally true.
I have reduced the problem to the following:

var x = {
y: function z() {}
};

and

// or: var x = function() {};
// that does not make a difference
function x() {};

// The following line triggers a "read error" (message; if you have
// enabled debugging)
x({
y: function z() {}
});

If you omit the `z', thereby making the function anonymous, the error
goes away. Can anyone with a KHTML-based UA confirm or deny that?
Can anyone explain that?
PointedEars
Mar 12 '06 #7
Thomas 'PointedEars' Lahn wrote:
I have reduced the problem to the following:

var x = {
y: function z() {}
};

and

// or: var x = function() {};
// that does not make a difference
function x() {};

// The following line triggers a "read error" (message; if you have
// enabled debugging)
x({
y: function z() {}
});

If you omit the `z', thereby making the function anonymous, the error
goes away. Can anyone with a KHTML-based UA confirm or deny that?
Can anyone explain that?


I have reported this now as
<URL:https://bugs.kde.org/show_bug.cgi?id =123529>
PointedEars
Mar 13 '06 #8
On 2006-03-13, Thomas 'PointedEars' Lahn <Po*********@we b.de> wrote:
Thomas 'PointedEars' Lahn wrote:

If you omit the `z', thereby making the function anonymous, the error
goes away. Can anyone with a KHTML-based UA confirm or deny that?
Can anyone explain that?


I tried this in Konqueror, and got a parse error. If I left out the z it
worked. It worked on firefox both ways.

var x = {
y: function z() { alert("hello"); }
};
x.y();

It is definitely a bug because the grammar defines a FunctionExpress ion
as:

function Identifier<opt> (FormalParamete rList<opt>) {FunctionBody}

So you should be allowed to have that Identifier there if you want one,
and you might need it if you wanted to make the function recursive.
Mar 13 '06 #9
VK

Richard Cornford wrote:
But you can use one SCRIPT element to import a file and simultaneously
define script within that element. It isn't a good idea to do so but it
is a reasonably commonly implemented facility; see the FAQ.


What FAQ? I hope it's not the official group FAQ at
<http://www.jibbering.c om/faq>? I looked at and I did not see anything
similar - but I might missed it. If so, it should be corrected
immediately as it's a gross error.

<script type="text/javascript" src="outer.js">
inner:
</script>

In this case inner block will be ignored and only outer file executed.
This is really a basic - it was this way ever since src attribute was
introduced. I am not aware of any browsers having different behavior.

Just for hell of it I tested the sample below on NN 4.5 (for my memory
check), IE.6.0, FF 1.5 and Opera 8.5:

<html>
<head>
<title>Script in Script doesn't work</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="outer.js">
window.alert('H i from inner!');
</script>
</head>

<body>

</body>
</html>

// where outer.js contains:
window.alert('H i from outer!');

Mar 14 '06 #10

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

Similar topics

4
44862
by: Bill | last post by:
I call a function in my .js file like this: onClick="location.href='blank.html' + generateSearchStringFromForm('section')" where section is the name of my form. The function is defined as follows: myFunction(k) {
2
2279
by: jsnX | last post by:
i want a function object that is a) initialized with an STL container foo b) will search foo for an object of type foo::value_type here is my code: ======================================================================== /* if we have a big list of things, and we went to check it * over and over for this or that thing, then we can use this * object to cache the list and consolidate queries of it.
2
1133
by: FredC | last post by:
OS Name Microsoft Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600 Total Physical Memory 1,024.00 MB MDE 2003 Version 7.1.3008 ..NET Framework 1.1 Version 1.1.4322 SP1 Microsoft Visual C# .NET 69462-335-0000007-18707 Crystal Reports for Visual Studio .NET AAP50-GS0000S-WCK00C3
11
44232
by: westplastic | last post by:
This one is driving me insane. The script works perfect on Firefox, but Internet Explorer keeps complaining about "Error Object Expected" and stuff like that. I've run it through Firefox's Java Console, and it comes back with no errors. Any pointers on this, would be much appreciated. <script type="text/javascript"> <!-- var p = new Array(0,0,0,0,0) var c = new Array(0,0,0,0,0,0,0,0,0)
26
5670
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized several parts of the DOM, but this does not include the window object. Thank you
12
5539
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
4
2766
by: loserdude84 | last post by:
Hi I keep getting the good old error 'Object Expected Error' on a site I recently built. I am really struggling with this one. Object Expected Error Line 66 <div class="headerBG_2"></div> <div class="contentBG_2"> <!-- flash banner --> <div class="flash_banner"> LINE 66 <script type="text/javascript">
1
3898
by: JOJO123 | last post by:
I got here in search of an answer to this Javascrpt question. I upgraded jave on XP Ie 7, acrobat 5.1 and suddenly can't open any pdf files on web sites using IE. I see u guys all say, this is a Javscript issue. but how do we, mere mortals who know nothing of anything about Java, scripts, etc, fix this? Is there a programm, does MS have any fix? is there any tweak like in the Registry, or whatever, how do I access anyihint java without in IE 7...
10
13302
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred." "Line:xxx" "Error: Object expected" and Debug says: "Microsoft JScript runtime error: Object expected."
2
5726
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%= ViewData %>" /> -
0
8472
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8909
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.