/    Sign up×
Community /Pin to ProfileBookmark

On mouseover image will change

Hi All,

i am giving the code snippet here so that you can understand what i am trying to achieve……. ?
<tr>
<td width=”208″ class=”brd” rowspan=”3″><img src=”../admin/upload/<?=$filename;?>” width=”400″ height=”300″ border=”0″></td>

<td height=”100″ valign=”middle” align=”center”><img src=”../admin/upload/<?=$pic1;?>” width=”100″ height=”75″ border=”0″></td>
<td height=”100″ valign=”middle” align=”center”><img src=”../admin/upload/<?=$pic2;?>” width=”100″ height=”75″ border=”0″></td>
</tr>
<tr>
<td valign=”middle” height=”100″ align=”center”><img src=”../admin/upload/<?=$pic3;?>” width=”100″ height=”75″ border=”0″></td>
<td valign=”middle” height=”100″ align=”center”><img src=”../admin/upload/<?=$pic4;?>” width=”100″ height=”75″ border=”0″></td>
</tr>
<tr>
<td valign=”middle” height=”100″ align=”center”><img src=”../admin/upload/<?=$pic5;?>” width=”100″ height=”75″ border=”0″></td>
<td valign=”middle” height=”100″ align=”center”><img src=”../admin/upload/<?=$pic6;?>” width=”100″ height=”75″ border=”0″></td>
</tr>

the $pic1,$pic2,$pic3…$pic6 are smaller images and the parent image is $filename.Now if i move the mouse pointer in pic1 then the mother image(filename) will be changed into pic1 image remaining in its original place.and so on…..

can you plz suggest me how can i do that.Is mouseover function will solve the problem…?or i think i have to write a small javascript function so that i can pass the id of pic1.pic2…to that function and if it is passed then the parent image will be changed to smaller image like pic1 or pic2 whatever it may be.

Thanks
Raj

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@stephen1davisApr 23.2006 — [code=html]<script type="text/javascript">

function change(which) {

document.getElementById('main').src="../admin/upload/<?=$" +which+ ";?>";
}
</script>


<tr>
<td width="208" class="brd" rowspan="3"><img id="main" src="../admin/upload/<?=$filename;?>" width="400" height="300" border="0"></td>

<td height="100" valign="middle" align="center"><img src="../admin/upload/<?=$pic1;?>" width="100" height="75" border="0" onmouseover="change('pic1');"></td>
<td height="100" valign="middle" align="center"><img src="../admin/upload/<?=$pic2;?>" width="100" height="75" border="0" onmouseover="change('pic2');"></td>
</tr>
<tr>
<td valign="middle" height="100" align="center"><img src="../admin/upload/<?=$pic3;?>" width="100" height="75" border="0" onmouseover="change('pic3');"></td>
<td valign="middle" height="100" align="center"><img src="../admin/upload/<?=$pic4;?>" width="100" height="75" border="0" onmouseover="change('pic4');"></td>
</tr>
<tr>
<td valign="middle" height="100" align="center"><img src="../admin/upload/<?=$pic5;?>" width="100" height="75" border="0" onmouseover="change('pic5');"></td>
<td valign="middle" height="100" align="center"><img src="../admin/upload/<?=$pic6;?>" width="100" height="75" border="0" onmouseover="change('pic6');"></td>
</tr>[/code]
Copy linkTweet thisAlerts:
@raj_2006authorApr 23.2006 — Hi Stephen....

Thanks for your suggestion first.....

But i am facing a error in this line:

document.getElementById('main').src="../admin/upload/<?=$" + which + "?>";

i think php with javascript concatenation have error.....

Please suggest.......Raj
Copy linkTweet thisAlerts:
@balloonbuffoonApr 23.2006 — It should probably just be:
[CODE]document.getElementById('main').src="../admin/upload/" + which;[/CODE]
And then each mouseover should be:
[CODE]onmouseover="change(this.src);"[/CODE]--Steve
Copy linkTweet thisAlerts:
@stephen1davisApr 23.2006 — that is better
Copy linkTweet thisAlerts:
@raj_2006authorApr 24.2006 — Hi...

GREAT success....... ?

This line is ok...document.getElementById('main').src="../admin/upload/" + which;

i just changed this one

onmouseover="change('<?=$pic1;?>');"...and so on...and it works....LOL.

Thanks again for your earnest co-operation.

With luv

Raj
Copy linkTweet thisAlerts:
@balloonbuffoonApr 24.2006 — Glad to see you got it working, but using this for the mouseover:
[CODE]onmouseover="change('<?=$pic1;?>');"[/CODE]is kind of redundant... The following doesn't have to be custom for each image!
[CODE]onmouseover="change(this.src);"[/CODE]But as long as its how you want it... ?

--Steve
Copy linkTweet thisAlerts:
@raj_2006authorApr 24.2006 — yeah i understand now but what was happening it was taking the upload folder path for twice.

it was coming in this way...

http://localhost/car/admin/upload/http://localhost/car/admin/upload/car1.jpg

Hope you understand.....?

Thanks

Raj
Copy linkTweet thisAlerts:
@balloonbuffoonApr 24.2006 — Oh yeah, I see what you mean.

But you could always change:
[CODE]document.getElementById('main').src="../admin/upload/" + which;[/CODE]to[CODE]document.getElementById('main').src=which;[/CODE]But maybe you should just leave it as-is since you know it works! ?

--Steve
×

Success!

Help @raj_2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...