Friday, March 30, 2012

Image swapping using DHTML

Image swapping using DHTML . . . .
The following code generates the image on button click events. . . 
Following is the code for the same :-
 
 




<html>
    <head>
        <title></title>
    </head>
    <body>
        <form>
            <img src="Desert.jpg" height="200" width="200" name="Sunset"><br />
            <input type="button" value="Img 1" name="b1" onclick="document.Sunset.src='Desert.jpg'"/>
            <input type="button" value="Img 2" name="b2" onclick="document.Sunset.src='Jellyfish.jpg'"/>

        </form>
    </body>
</html>


Screenshots :-

On clicking Img 1, shows "Desert"

On clicking Img 2, shows "Jellyfish"
 

No comments:

Post a Comment