By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,010 Members | 2,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,010 IT Pros & Developers. It's quick & easy.

swapping images (more than 1 instance)?

P: n/a
Hello,

Way back in 2000 Ken Cox put up this code for swapping images on a
button.

I cannot work out how to use it so that more than 1 button can use it.
I guess the problem is knowing how to deal with the intImage value?

Cheers

Geoff

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>
intImage = 2;
function swapImage() {
switch (intImage) {
case 1:
IMG1.src =
"http://www.microsoft.com/library/toolbar/images/mslogo.gif"
intImage = 2
return(false);
case 2:
IMG1.src =
"http://msdn.microsoft.com/msdn-online/start/images/msdn-logo.gif"
intImage = 1
return(false);
}
}
</SCRIPT>
</HEAD>
<BODY>
<IMG id="IMG1" name="IMG1"
src="http://www.microsoft.com/library/toolbar/images/mslogo.gif"
onclick="swapImage();">
</BODY>
</HTML>
Jan 30 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Geoff Cox < said the following on 1/30/2008 4:17 AM:
Hello,

Way back in 2000 Ken Cox put up this code for swapping images on a
button.
And he wrote an IE-only script.
I cannot work out how to use it so that more than 1 button can use it.
I guess the problem is knowing how to deal with the intImage value?
Throw it away and start over.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 30 '08 #2

P: n/a
On Jan 30, 10:48*am, Randy Webb <HikksNotAtH...@aol.comwrote:
Be careful with that. The .src property of an image includes the full
URL to the file. Not just the filename itself.
Thanks. It's funny you should mention that. I did it that way because
the url was a long string of goop and I was being lazy.

Jan 30 '08 #3

P: n/a
On Jan 30, 2:59*pm, Geoff Cox <<>wrote:
sorry Doug - stupid of me - I missed that for some reason.

Cheers

Geoff
No problem. Good luck.
Jan 30 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.