Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script Error - Object Expected error

    Thank you for taking the time to look at my problem. I know I am missing something right in front of me but I just can't figure this one out.

    The code below is part of a page generated by a PHP script. The final product is a mix of html, PHP, mySQL and javascript. A page contains multiple iterations of the code below, changing only the number in the function (i.e. cr1(), cr2(), cr3(), etc...)

    Code:
         <td valign=top>[<a href='javascript:cr3();'>OPEN</a>]</td>
         <td valign=top>[<a href='javascript:ar3b();'>OPEN</a>]</td>
         <td valign=top>[<a href='javascript:ar3b();'>OPEN</a>]</td></tr>
           <script><!-- function cr3(){ document.cr3a.submit(); } //--></script>
           <form name='cr3a' target='_blank' method='post' action='gameRequest.php'>
            <input type=hidden name=ea value='email@address.net'>
            ... more data in here ...
            <input type=hidden name=pos value='Center'>
           </form>
           <script><!-- function ar3b(){ document.ar3c.submit(); } //--></script>
           <form name='ar3c' target='_blank' method='post' action='gameRequest.php'>
            <input type=hidden name=ea value='email@address.net'>
            ... more data in here ...
            <input type=hidden name=pos value='AR'>
           </form>
    in the error handler box I get the following
    Line: 1
    Char: 1
    Error: Object Expected
    Code: 0

    If anyone has any ideas what might be wrong do tell, I have been trying to get it working for a couple days now. Thanks again for taking the time to help me out.

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    375
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That looks like an Internet Explorer error. You will probably get much more information if you fire the page up in Firefox or NS7.2 and use the javascript console.

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunately FireFox doesn’t give me much more info on the problem.

    Error cr3 is not defined
    Source File: javascript:cr3()
    Line: 1

    I'm not sure why it’s saying it's not defined. If it was C++ I would think it was because I put the function after the call. But I’ve tried putting the function first and still end up with the same error =x

    Any more ideas are most welcome because this is confounding the heck out of me.

  • #4
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    The objects used in javascript still have to come before the function call... So your error must be somewhere else if you still get an error after you place the function calls first...

    You might want to try this instead:
    Code:
         <td valign=top>[<a href='javascript:cr3();'>OPEN</a>]</td>
         <td valign=top>[<a href='javascript:ar3b();'>OPEN</a>]</td>
         <td valign=top>[<a href='javascript:ar3b();'>OPEN</a>]</td></tr><form name='cr3a' target='_blank' method='post' action='gameRequest.php'>
    <input type=hidden name=ea value='email@address.net'>
            ... more data in here ...
    <input type=hidden name=pos value='Center'>
    </form>
    <form name='ar3c' target='_blank' method='post' action='gameRequest.php'>
    <input type=hidden name=ea value='email@address.net'>
            ... more data in here ...
    <input type=hidden name=pos value='AR'>
    </form>
    <script language="JavaScript"><!--
    function cr3(){ document.cr3a.submit(); }
    function ar3b(){ document.ar3c.submit(); }
     //--></script>
    HTH,

    -sage-

    Edit: I also realized since these scripts are referencing form objects they have to be placed after the forms are created... I tested this and it works...
    Last edited by sage45; 07-09-2005 at 02:36 AM.
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would suspect the problem is that there is no submit button...
    submit() acts much like click()...

    .....Willy

  • #6
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Not true... You can submit a form without a submit button...

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #7
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Strange, when I put the statements together, under one script tag instead of two, it works.

    But I don't have any clue why. Everything I know about javascript says that two tags should work exactly the same way as one.

    In any case thanks for the fast help =D

    <EDIT>
    okay, wow, I found out what it was. It's what I get for being a fool and trying to tighten up my code. The error here was none of the above, but sage45 still sort of pointed me in the right direction.

    Your going to love this. The reason it didnt work was becuase the function was on the same line as the <!-- comment, moving the function to a new line solved the problem.
    Last edited by Starwin; 07-09-2005 at 10:59 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •