473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Rollover Button script not working

I'm new to html and Javascript and have been given an assignment from a
friend to get me up to speed. I've followed instructions from Thomas
A. Powells book HTML THE COMPLETE REFERENCE 3rd Edition on how to code
basic Rollover Buttons using javascript but can't get them to work at
all. This is my first experince coding with Javascript.

Please see http://www.skatopia.co.nz/Phil_homew...l_answer2.html

The code is only for the first button at this point (ie the INITIATE
button on the navigation near the top of the page) I wanted to
understand it before applying the code to the other buttons.

ps - In an effort to not be influenced by the code from WYSIWYG editors
I wrote the code in Notepad. I've been validating the code at
http://validator.w3.org/, and used Dave Raggetts TIDY ONLINE to clean
up my code (http://valet.htmlhelp.com/tidy/)

Feb 3 '06 #1
2 1357
> The code is only for the first button at this point (ie the INITIATE
button on the navigation near the top of the page) I wanted to
understand it before applying the code to the other buttons.


I don't see any images called "buttonon" in your images directory.

Feb 3 '06 #2

old_school_skater wrote:
I'm new to html and Javascript and have been given an assignment from a
friend to get me up to speed. I've followed instructions from Thomas
A. Powells book HTML THE COMPLETE REFERENCE 3rd Edition on how to code
basic Rollover Buttons using javascript but can't get them to work at
all. This is my first experince coding with Javascript.

Please see http://www.skatopia.co.nz/Phil_homew...l_answer2.html

The code is only for the first button at this point (ie the INITIATE
button on the navigation near the top of the page) I wanted to
understand it before applying the code to the other buttons.
Next time be more descriptive about what "doesn't work", and it would
be helpful to post the script to diagnose.

This is the script you have:
<script type="text/javascript" language="JavaScript">
The language attribute is deprecated, just stay with the type
attribute:

<script type = "text/javascript">
buttonoff = new Image();
buttonoff.src = "buttonoff.gif";
buttonon = new Image();
buttonon.src = "buttonon.gif";
These are being used as global variables. It's usually a good idea to
have them declared them somewhere.

var buttonoff, buttonon;
document[imageName].src = eval(imageName+"on.src");
document[imageName].src = eval(imageName+"off.src");


Did the book tell you to use the eval function? The eval function is
generally not necessary. Also, you are not using the images
collection. Instead do the following:

document.images[imageName].src = buttonon.src;
document.images[imageName].src = buttonoff.src;

Feb 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oxnard | last post by:
Here's the script section: function change(color){ var el=event.srcElement if (el.tagName=="INPUT"&&el.type=="button") event.srcElement.style.backgroundColor=color } function jumpto2(url){...
5
by: jedbob | last post by:
I used Adobe Imageready to build a simple rollover navigation bar, where the text will change color on a mouse over. The working example can be found at:...
6
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.