...

View Full Version : Script Error - Object Expected error



Starwin
07-08-2005, 11:26 PM
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...)



<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.

jscheuer1
07-09-2005, 12:00 AM
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.

Starwin
07-09-2005, 01:51 AM
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.

sage45
07-09-2005, 02:17 AM
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:
<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...

Willy Duitt
07-09-2005, 02:46 AM
I would suspect the problem is that there is no submit button...
submit() acts much like click()...

.....Willy

sage45
07-09-2005, 03:26 AM
Not true... You can submit a form without a submit button...

-sage-

Starwin
07-09-2005, 10:49 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum