Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Dreaded Object Required

Hi

I've got a simple rollover (well, supposed to be simple) but I can't get the thing to work - 'Error, Object Required' is the error message I get; I've tried everything, even copying and pasting code that is working with the same script but it's just not having it!

Please help

here's the relevant code:

<script src="includes/java_function.js" language="javascript" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">

function imgOver() {
}

function imgOut() {
}
</script>


then below in the body this is the html for example:

 <a href="mailto:[email protected]?subject=website%20e nquiry" onmouseover="imgover('email')" onmouseout="imgout('email')">
                    <img src="image_bin/email_up.gif" alt="" name="email" width="161" height="11" border="0">

below is the script in the java_function.js file:

home_up = new Image
email_up = new Image
about_up = new Image
vehicles_up = new Image
terms_up = new Image

home_over = new Image
email_over = new Image
about_over = new Image
vehicles_over = new Image
terms_over = new Image

home_up.src = "image_bin/home_up.gif"
email_up.src = "image_bin/email_up.gif"
about_up.src = "image_bin/about_up.gif"
vehicles_up.src = "image_bin/vehicles_up.gif"
terms_up.src = "image_bin/terms_up.gif"

home_over.src = "image_bin/home_over.gif"
email_over.src = "image_bin/email_over.gif"
about_over.src = "image_bin/about_over.gif"
vehicles_over = "image_bin/vehicles_over.gif"
terms_over.src = "image_bin/terms_over.gif"

function imgOver(thisImg) {
    document[thisImg].src = "image_bin/" + thisImg + "_over.gif"
}

function imgOut(thisImg) {
    document[thisImg].src = "image_bin/" + thisImg + "_up.gif"
}

It's probably something very simple that's staring at me in the face!

thanks alot

Adam



 
Old October 21st, 2004, 12:06 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Your functions are called imgOver and imgOut but you call imgover etc. Object required in JavaScript nearly always means you've got the case wrong on a function name.

--

Joe
 
Old October 21st, 2004, 01:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

phew, thanks for that Joe - you just saved me from going completely demented

 
Old October 21st, 2004, 02:17 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Reminds me of when I first started playing with JavaScript, I spent hours staring at code that errored with "object reqired" because I had used "If" instead of "if" :)

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object required jpaul VB Databases Basics 5 November 14th, 2007 12:10 PM
object required alitoday Classic ASP Components 1 December 28th, 2004 01:17 AM
object required shoakat Classic ASP Databases 7 November 23rd, 2004 07:38 PM
error....Object required: '' sassenach Classic ASP Databases 2 August 4th, 2003 03:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.