Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-30-2005, 02:36 PM   #1 (permalink)
HuntHerr
Registered User
 
Join Date: Jan 2005
Posts: 2
HuntHerr is on a distinguished road
Image swap in different table cell

Anyone know the code for image swap/rollover in which on mouse rollover, an image in a different cell changes?
thanks
HuntHerr is offline   Reply With Quote
Old 01-30-2005, 02:55 PM   #2 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
Code:
function findObj(objID){ return document.getElementById?document.getElementById(objID):document.all?document.all[objId]:null; }

function changeImage(newImgSrc) {
    var newImg = findObj("newImg");    
    if (!newImg) return;

    newImg.src = newImgSrc;
}
The HTML that could go with this is:

Code:
<html>
<head>
<script><!-- INSERT SCRIPT HERE --></script>
</head>
<body>

<table>
<tr>
    <td>
        <span id="oldImg" onmouseover="changeImg('newImg.jpg');">A cell</span>
    </td><td>
        <img id="newImg" src="oldmg.jpg">
    </td>
</tr>
</table>

</body>
</html>
Obviously this might need some work to make it more exensible.. but the base code is there. Furthermore, I don't know if you need the image to change back after the mouse leaves as well.

If you need more info, just ask.

-Ted
__________________
while(1) fork();

Last edited by ender; 01-30-2005 at 03:03 PM. Reason: code error .. arrg
ender is offline   Reply With Quote
Old 01-30-2005, 06:13 PM   #3 (permalink)
HuntHerr
Registered User
 
Join Date: Jan 2005
Posts: 2
HuntHerr is on a distinguished road
Not working for me, is this the correct code?

Code:
<html>
<head>
<script>
function findObj(objID){ return document.getElementById?document.getElementById(ob  jID):document.all?document.all[objId]:null; }

function changeImage(newImgSrc) {
    var newImg = findObj("jack2.jpg");    
    if (!newImg) return;

    newImg.src = newImgSrc;
}</script>
</head>
<body>

<table width="469">
<tr>
    <td width="227">
        <span id="oldImg" onmouseover="changeImg('jack2.jpg');">a cell</span>
    </td><td width="230">
        <img id="newImg" src="jack.jpg">
    </td>
</tr>
</table>

</body>
</html>
HuntHerr is offline   Reply With Quote
Old 01-30-2005, 06:47 PM   #4 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
No.. try replacing the findObj('jack2.jpg') with findObj('newImg');
__________________
while(1) fork();
ender is offline   Reply With Quote
Reply

Bookmarks

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a dynamic Table cell xtrax_22 PHP 18 08-31-2004 09:08 AM
table cell highlight and text change on mouseover EscapeCharacter HTML, XML, Javascript, AJAX 13 09-09-2003 12:28 AM
How do I embed a single image in the bg of a table w/o tiling? sde HTML, XML, Javascript, AJAX 4 08-27-2002 08:36 AM


All times are GMT -8. The time now is 01:34 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting