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

Discussion in 'Javascript' started by Danny, Jul 18, 2003.

  1. Danny

    Danny Guest

    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>
     
    Danny, Jul 18, 2003
    #1
    1. Advertising

  2. (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 -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jul 18, 2003
    #2
    1. Advertising

  3. Danny

    Lee Guest

    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();
     
    Lee, Jul 18, 2003
    #3
  4. I get an "Error: Object expected" and I don't know why

    JRS: In article <>, seen
    in news:comp.lang.javascript, Danny <> 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.
     
    Dr John Stockton, Jul 18, 2003
    #4
  5. Danny

    Danny Guest

    It finally works. Thanks for the help.

    Danny
     
    Danny, Jul 18, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DP
    Replies:
    0
    Views:
    1,183
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    991
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,262
    Smokey Grindel
    Dec 2, 2006
  4. Daniel Berger
    Replies:
    4
    Views:
    125
    Daniel Berger
    Sep 28, 2008
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    282
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page