Current location: Hot Scripts Forums » General Web Coding » JavaScript » Rollover


Rollover

Reply
  #1 (permalink)  
Old 05-25-05, 01:22 AM
blessedrub blessedrub is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Rollover

I have a question does anyone know how to do the following... Say I have word1,word2,word3 as links on the left but as you rollover them ImageHere changes as you rollover each link How do I do that?
Reply With Quote
  #2 (permalink)  
Old 05-25-05, 05:16 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
yes it's possible
I did this quickly! man, Javascript is easy!
Code:
<script language="javascript">
function changeImage(image_id, new_image, new_width, new_height)
{
    var image = document.getElementById(image_id);

    if (new_width > 0)
        image.width = new_width;

    if (new_height > 0)
    	image.height = new_height;

    image.src = new_image;
}
</script>
<table width="100%">
	<tr>
		<td width="10%" align="center">
		<a href="javascript:void(0);" onmouseover="changeImage('changable', 'button7.jpg', 150, 7);">
		word1</a></td>
		<td width="90%" rowspan="3" align="center">
		<img id="changable" border="0" src="image.jpg" width="334" height="240">
		</td>
	</tr>
	<tr>
		<td width="10%" align="center">
		<a href="javascript:void(0);" onmouseover="changeImage('changable', 'button8.jpg', 150, 7);">
		word2</a></td>
	</tr>
	<tr>
		<td width="10%" align="center">
		<a href="javascript:void(0);" onmouseover="changeImage('changable', 'button4.jpg', 150, 7);">
		word3</a></td>
	</tr>
</table>
I created this changeImage function that will change the image!
you have to pass to the function 4 parameters:
1- the image id that will be changed when hovered over it
2- new image name (path)
3- new width
4- new height
you can ignore the last 2 arguments.
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 05-25-05, 09:22 AM
blessedrub blessedrub is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Thankyou so much you are the bomb I've been trying to do this forever.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Special rollover scripts alt-088 JavaScript 4 10-17-05 07:32 PM
Flatfile db, table rollover bangeren05 PHP 3 04-30-05 10:33 AM
Rollover links Baho HTML/XHTML/XML 1 02-03-05 06:32 AM
Help with rollover image submit button landboy HTML/XHTML/XML 3 05-30-04 11:17 AM
[PHP] How to have rollover images? dihan PHP 2 01-10-04 10:23 AM


All times are GMT -5. The time now is 10:48 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.