Click to See Complete Forum and Search --> : Chaging code without reloading page


batookee
09-09-2003, 05:35 PM
There may be a very easy way of doing this either with DHTML or JS but what I'm trying to do is change a table background image by clicking a link but I don't want the page to re-load. Could someone point me in the right deirection?

Fang
09-10-2003, 01:34 AM
One way is to define two classes containing the images and then swapping the class.
In this example click on the table.

<style type="text/css">
<!--
table.image1 {
background-image : url(Images/img1.gif);
}
table.image2 {
background-image : url(Images/img2.gif);
}
-->
</style>

<table onclick="this.className=(this.className=='image1')? 'image2' : 'image1';" class="image1" border="1" cellpadding="0" cellspacing="0" summary="image swapping">
<tr><td>Swap background image</td></tr>
</table>