Seeking advice for switching image. =D

This is a discussion on "Seeking advice for switching image. =D" within the JavaScript Forum section. This forum, and the thread "Seeking advice for switching image. =D are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Nov 18th, 2007, 10:19
New Member
Join Date: Nov 2007
Location: san jose
Age: 19
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Seeking advice for switching image. =D

Hi,

I am building family website for my grandfather and I am somewhat struggling at the moment on switching images...

Once the second picture shows up, I am having trouble when the second image is clicked, the second image is not replaced by the first image...Am I missing something?

Please assist hehehe =D

HTML: Select all
<html>
<head>
<title>Image switch</title>
<script language="Javascript">

function rollover ()
{
document.picture.src = "http://www.coolest-gadgets.com/wp-content/uploads/talking-beer-glass.jpg";
}


</script>
</head>
<body>

<img src="http://www.beer.thetazzone.com/images/drinkBeer9.jpg" name="picture" border="0" onClick="rollover()">

</body>
</html>




Last edited by c010depunkk; Nov 18th, 2007 at 11:26. Reason: please use [HTML] tags when posting HTML
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 19th, 2007, 12:48
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Seeking advice for switching image. =D

Are you trying to make a sort of gallery?

Have you tried Lightbox?

I use it on my portfolio ... when you click on one of my clients you can then just click next or prev and scroll through them all.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 19th, 2007, 17:48
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Seeking advice for switching image. =D

Do you want the images to toggle between each other when clicked on?

In that case you are missing something. You just have 1 function to turn image 1 into image 2. You need to update your script to alternate the images.


HTML: Select all
    <html>
    <head>
    <title>Image switch</title>
    <script type="text/javascript">

    function changeImage ()
    {

    var img1 = "http://www.beer.thetazzone.com/images/drinkBeer9.jpg";
    var img2 = "http://www.coolest-gadgets.com/wp-content/uploads/talking-beer-glass.jpg"

     if(document.picture.src == img1) {

       document.picture.src = img2;

       } else {
     
       document.picture.src = img1;

     }

    }
    </script>
    </head>
    <body>

    <img src="http://www.beer.thetazzone.com/images/drinkBeer9.jpg" name="picture" onClick="changeImage()">

    </body>
    </html>
This code will switch between images when clicked on. You can change what images show up by changing the variables "img1" and "img2" at the top of the script.

Whatever you want the default image to be, write in the src="..." part of the image tag.

Hope this helps,
Blake
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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
switching backgound image pahvi67 JavaScript Forum 4 Jan 16th, 2008 13:27
Seeking Advice for Multi-Language website design jssaggu Scripts and Online Services 0 Jun 1st, 2007 20:44
Background Image advice dawg9 Web Page Design 12 Mar 31st, 2007 02:12
'Sample' image overlay advice needed Demon Templates Graphics and 3D 5 Mar 9th, 2007 11:49
Seeking Some Advice - Users & Passwords & Intergration Micky-D PHP Forum 2 Aug 15th, 2006 11:35


All times are GMT. The time now is 16:27.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42