By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
It finally works. Thanks for the help.

Danny
Jul 20 '05 #4

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.