PDA

View Full Version : Can this be done w/ Javascripts?


Tony
01-02-2003, 02:52 PM
I am wondering if this can be done with Javascripts:

I have an html table with 2 cells that have 2 different images inside them.

I want to be able to make a mouse rollover....but when a user puts his mouse over 1 cell...... the 2 cells rollover with their images.....

Can this be done with Javascripts or how can I do this?


Thanks!

Htmlwiz
01-02-2003, 04:06 PM
bye!

piz
01-02-2003, 04:12 PM
yes it is possible.

<html>
<head>
<title>.:: united.scripts.com sample ::.</title>
<script>
function rollover(src1, src2){
document.getElementById("img1").src = src1;
document.getElementById("img2").src = src2;
}
</script>
</head>

<body>
<table>
<tr>
<td onmouseover="rollover('image1over.jpg', 'image2over.jpg');" onmouseout="rollover('image1.jpg', 'image2.jpg');">
<img src="image1" id="img1">
</td>
<td>
<img src="image1" id="img2">
</td>
</tr>
</table>
</body>


you have to replace the src values and the attributes of the rollover-function, when it is called in the mousover event of the first <td> with the src of your images.

Saludo
piz

piz
01-02-2003, 04:13 PM
Originally posted by Htmlwiz
ummm.......yah. but just use it as html!

How do you want to do that with HTML?