Now javascript is getting really stupid. Or is it me ?!
Hi,
I cannot for the life of me see what's wrong with this very simple bit of code;
Searching...
Searching...
Number of properties found 1
<script language="javascript">
function timeout()
{
document.gotosearchresults.submit();
}
</script>
It should simply show the page and then automatically submit it once it's loaded. However I get an "Object doesn't support this property or method" error. Which I think it completely wrong. I've used this code on another project with no problem whatsoever.
cheers
Andy
(P.S. it's a lot shorter than my last post !!!)
[email protected]
www.palomex.com
Interactive Website Design and Development
Jack Michaelson posted this at 10:38 — 4th March 2002.
He has: 1,733 posts
Joined: Dec 1999
I have some questions about the script:
-I assume that you placed the 'x' of action="x" there on purpose, just to show us the script?
-Why do you submit the form onload and have a submit button?
Shakespeare: onclick || !(onclick)
andymac posted this at 10:55 — 4th March 2002.
They have: 14 posts
Joined: Dec 2001
Hi,
Thanks for the quick response...
(1) Yep, the "action=x" is just there cos I've not written the page that it's going to yet !
(2) There is a submit button because I was just testing that it wasn't some other problem. Pressing the submit button works fine. It will be removed on the final version
cheers
Andy
[email protected]
www.palomex.com
Interactive Website Design and Development
Jack Michaelson posted this at 11:06 — 4th March 2002.
He has: 1,733 posts
Joined: Dec 1999
I removed the onload and everything worked fine.
So, I think you cannot submit a form through an onload in a body. Seems logical too, because if it could be done it would be very easy to let a mailserver crash by (accidently) bombing it.
Anyway I'm not sure, so maybe wait for an answer from the real gurus on this forums
Shakespeare: onclick || !(onclick)
andymac posted this at 11:10 — 4th March 2002.
They have: 14 posts
Joined: Dec 2001
Hi Jack,
I don't understand why you couldn't do it on an onload. As I understand it onload fires off once the form is fully downloaded. As this code works perfectly fine on another project (I'd Cut&Pasted the code) - that's the really strange thing.
thanks again
Cheers
Andy
[email protected]
www.palomex.com
Interactive Website Design and Development
Suzanne posted this at 20:42 — 4th March 2002.
She has: 5,507 posts
Joined: Feb 2000
You can't call a function you haven't declared yet. Put the JavaScript code in the head element.
andymac posted this at 20:53 — 4th March 2002.
They have: 14 posts
Joined: Dec 2001
I'll try it, but I don't follow why it doesn't work as I think it should. If the onload event fires after the document has fully loaded then the function has been declared. It also doesn't explain why it fails if I do onload="document.gotosearchresults.submit();". Then there's no function, just the object being referenced directly.
It also doesn't explain why it works on another project but doesn't on this one !
All very odd. I'm currently looking at Javascript as a necessary evil
cheers
Andy
(Can you spot I'm an ASP person )))
[email protected]
www.palomex.com
Interactive Website Design and Development
Anonymous posted this at 19:43 — 5th March 2002.
They have: 5,633 posts
Joined: Jan 1970
It may be that there is a space between 'java' and 'script' in the unload statement.
Suzanne posted this at 21:58 — 5th March 2002.
She has: 5,507 posts
Joined: Feb 2000
because it reads it in order. The function isn't there yet. onLoad means on load! When the page is loading, not when the page has finished loading, then do it.
andymac posted this at 22:42 — 5th March 2002.
They have: 14 posts
Joined: Dec 2001
The saga continues...
Ok, I've tried moving the <script> block into the header. So it loads before the block where it's called
That doesn't work.
Now I've tried sticking this;
Show results
in the body
I click on the link and I get the same error.
It's something to do with the javascript not believing that the form is an object when it is.
AAAAARRRRGGGGHHHHHHHHHH!!!!!!!!!!!!!
(thanks for all the replies !)
cheers
Andy
[email protected]
www.palomex.com
Interactive Website Design and Development
Suzanne posted this at 03:04 — 6th March 2002.
She has: 5,507 posts
Joined: Feb 2000
Try using forms[0] instead of gotosearchresults.
Why aren't you just using this onSubmit, btw? You're trying to submit a form from an anchor tag? No can do, buckaroo.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.