Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 3
Trades: 0
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
 
 
Register now for full access!
Old 01-25-2006, 02:44 PM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
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 02:50 PM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 01-25-2006, 05:40 PM
Junior Talker

Posts: 3
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.55204 seconds with 12 queries