Reply
Variables and image rollovers
Old 01-24-2006, 03:52 PM Variables and image rollovers
Junior Talker

Posts: 2
Hi, I'm not trying to do your one of the mill rollover, I want to change ONE image to one of several DIFFERENT images depending on the image calling the rollover.



This distant rollover works:

Code:
     
function top*****ange() { if (document.images) { document.topbit.src=01bit.jpg); } }
but how do I change it to use a variable ?

Code:
     
function top*****ange(name) { if (document.images) { document.topbit.src=name+ ".jpg"); } }
it's the punctuation around the name+ .jpg bit that's my problem....

any help would be much appreciated


I call then call it using

Code:
onmouseover ="top*****ange(longbit_gens)"
changing the bit in brackets depending on the pic I want displayed in IMG topbit.
highab is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-25-2006, 01:44 PM
funkdaddu's Avatar
Web Design Snob

Posts: 636
You've got the basic idea, but your code is messed up: What's with the asterix's? I don't think those are legal characters for function names... or is that a curse word topB1TCHange - I get it. Also, you have an extra ")" in your code:
Code:
function 
switchImage(name) {
    if (document.images) {
        document.topbit.src = name + ".jpg";
    }
}
in your first example, you need the image location in quotes:
document.topbit.src="01bit.jpg";

as well as when you call it:
onmouseover ="switchImage('longbit_gens');"

if they don't have quotes around them it's a variable, not a string.

Last edited by funkdaddu : 01-25-2006 at 01:50 PM.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 01-25-2006, 04:40 PM
Junior Talker

Posts: 2
aha, thanks! Knew it had to be something pretty easy.

Sorry for the asterisks.... wasn't intended in any way, I just wanted to change "topBit" that's all!
highab is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Variables and image rollovers
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11353 seconds with 12 queries