473,507 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I get an "Error: Object expected" and I don't know why

Hi I don't understand why I keep getting "Error: Object expected" I
tried different things and haven't been able to solve it. I'm a newbie
so I'm not sure what I'm doing wrong. The debugger breaks at the
<BODY> Tag of my code so I'm thinking the problem is with my
InitPage() function. I appreciate the advice. Here is my code.

<SCRIPT LANGUAGE="Javascript">
<!--

var flag = false;

function InitPage()
{

document.MyForm.Datebox.value = getCurrentDate();
}
function MyForm_onsubmit()
{

// Check Date Open Box
if ( checkDate(document.MyForm.Datebox.value) == false )
{ alert("You must provide a Date")
return false;
}
}

// -->
</SCRIPT>

<HTML>
<HEAD>
<TITLE>Dummy Title </Title>
</HEAD>
<BODY onload="InitPage();" bgColor=#0a357e text=White Link=White
vLink=White aLink=White>
<form name = "MyForm" method="post" action="addIssue.asp"
onsubmit= "return MyForm_onsubmit()" >

Date Opened <input name="Datebox">&nbsp;Format: dd/mm/YYYY &nbsp;
<input type="submit" value="Save Details" name="Save_Button">&nbsp;
<input type="reset" value="Clear Details" name="Clear_Button">
</form>
</BODY>
</HTML>
Jul 20 '05 #1
4 47607
da***********@pacbell.net (Danny) writes:
Hi I don't understand why I keep getting "Error: Object expected" I
tried different things and haven't been able to solve it. I'm a newbie
so I'm not sure what I'm doing wrong. The debugger breaks at the
<BODY> Tag of my code so I'm thinking the problem is with my
InitPage() function. I appreciate the advice. Here is my code.
<SCRIPT LANGUAGE="Javascript">
<script type="text/javascript">
The type attribute is mandatory in HTML 4, the language attribute is
deprecated.
<!--
This HTML comment is not needed in Javascript.
var flag = false;

function InitPage()
{
document.MyForm.Datebox.value = getCurrentDate();
I recommend writing
document.forms['MyForm'].elements['Datebox'].value = ...
but that is just a personal peeve.

The problem seems to be that the "getCurrentDate" function is not
defined anywhere.
// -->
unneeded.
</SCRIPT>

<HTML>
Script elements must be inside either head or body. It is illegal to
put them before <head>.
<HEAD>
<TITLE>Dummy Title </Title>
</HEAD>
<BODY onload="InitPage();" bgColor=#0a357e text=White Link=White


bgColor="#0a357a"
Unquoted attributes are not allowed to contain the character "#".
(Just quote all attributes, and you can stop worrying :).
Hope this helps.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lee
da***********@pacbell.net said:

Hi I don't understand why I keep getting "Error: Object expected" I
tried different things and haven't been able to solve it. I'm a newbie
so I'm not sure what I'm doing wrong. The debugger breaks at the
<BODY> Tag of my code so I'm thinking the problem is with my
InitPage() function. I appreciate the advice. Here is my code.
function InitPage()
{

document.MyForm.Datebox.value = getCurrentDate();
}


You don't seem to have defined a function called getCurrentDate();

Jul 20 '05 #3
It finally works. Thanks for the help.

Danny
Jul 20 '05 #4
JRS: In article <16**************************@posting.google.com >, seen
in news:comp.lang.javascript, Danny <da***********@pacbell.net> posted
at Fri, 18 Jul 2003 11:02:41 :-
Hi I don't understand why I keep getting "Error: Object expected" I
tried different things and haven't been able to solve it. I'm a newbie
so I'm not sure what I'm doing wrong. The debugger breaks at the
<BODY> Tag of my code so I'm thinking the problem is with my
InitPage() function. I appreciate the advice. Here is my code.
...


When embedding script in HTML, it is desirable that the HTML itself
should be valid. In the opinion of W3's TIDY (30 Apr 2000) which I got
from http://www.w3.org/People/Raggett/tidy/ yours is not.

Tidy (vers 30th April 2000) Parsing console input (stdin)
line 1 column 1 - Warning: <script> lacks "type" attribute
line 26 column 1 - Warning: inserting missing 'title' element
line 27 column 1 - Warning: <head> isn't allowed in <body> elements
line 28 column 1 - Warning: <title> isn't allowed in <body> elements
line 29 column 1 - Warning: </head> isn't allowed in <body> elements
line 30 column 1 - Warning: <body> isn't allowed in <body> elements

HTML Tidy for Windows released on 1st February 2003 has 8 further
complaints.
While HTML errors do not necessarily prevent script from working, those
look important.

Otherwise, be sure that all objects used are pre-existent or are first
created.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #5

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

Similar topics

2
9776
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
11
2434
by: Florian Loitsch | last post by:
I'm currently writing a JS->Scheme compiler (which, using Bigloo, automatically yields a JS->C, JS->JVM, JS->.NET compiler), and have a question concerning the function-parameters: According to...
4
1481
by: Toufik | last post by:
Hi, I've the folowing error "Concurency violation, The update command affected 0 records", when I execute the save command "DA.Update(DS, "tblName")" DA is a dataadapter linked to a...
16
47660
by: Steve Chapel | last post by:
When I load the page <https://bugzilla.mozilla.org/attachment.cgi?id=237739with Internet Explorer 7 RC 1, I get the error "Object Expected" at line 174. When I click on the button, I also get the...
10
13283
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."...
1
2089
by: nelsonivan | last post by:
Hi, i'm trying to reference some objects using reflection and Late Binding accessing. The Object API to his methods it's easy to understand, and it's as "Object.Method" - aka....
14
2494
by: =?GB2312?B?zPC5zw==?= | last post by:
Howdy, I wonder why below does not work. a = object() a.b = 1 # dynamic bind attribute failed... To make it correct, we have to create a new class: class MyClass(object): pass a =...
2
5706
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="<%=...
0
7223
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,...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7314
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,...
0
7372
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...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.