Results 1 to 3 of 3

Thread: Onclick change image and onclick change again

  1. #1
    Join Date
    May 2014
    Posts
    203
    Thanks
    28
    Thanked 5 Times in 5 Posts

    Default Onclick change image and onclick change again

    I would like to make this

    zoom script, upon click, to change an image elsewhere on the page. and upon another click, change it back to the first image again.

    Code:
    <input type="image"  src="up2.png" width="10%" onclick="zoom (1.2)"/>
    
    <input type="image" src="down2.png" width="10%" onclick="zoom(0.9)"/>
    the idea being that each time a click happens, it zooms a bit and changes a pic of a character nearby. and upon another click zooms a bit more and shows the original pic of the character again, and repeats that same sequence, each time it's clicked. so original pic, second pic, original pic, second pic = click click click click and so on .

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <input type="button" name="" value="Rotate" onclick="Rotate('i1',['http://www.vicsjavascripts.org/StdImages/Egypt6.jpg','http://www.vicsjavascripts.org/StdImages/Egypt7.jpg']);" />
    <img id="i1" src="http://www.vicsjavascripts.org/StdImages/Egypt6.jpg" />
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Rotate(id,a){
     var i=document.getElementById(id),o=Rotate[id],z0=0,n;
     if (i&&!o&&a instanceof Array){
      for (;z0<a.length;z0++){
       n=new Image();
       n.src=a[z0];
       a[z0]=n;
      }
      o=Rotate[id]={
       a:a,
       n:0
      }
     }
     if (o){
      o.n=++o.n%o.a.length;
      i.src=o.a[o.n].src;
     }
    }
    
    /*]]>*/
    </script>
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    jundo12 (05-09-2014)

  4. #3
    Join Date
    May 2014
    Posts
    203
    Thanks
    28
    Thanked 5 Times in 5 Posts

    Default

    thanks! that works great!

Similar Threads

  1. Resolved How do you change mouseover to onclick?
    By maximumovertime in forum Dynamic Drive scripts help
    Replies: 9
    Last Post: 01-08-2011, 01:26 PM
  2. Change Image On Mouseover, retain onclick And play a sound!
    By TicTacWoe in forum Looking for such a script or service
    Replies: 2
    Last Post: 01-06-2010, 05:48 PM
  3. Replies: 0
    Last Post: 10-23-2007, 09:35 AM
  4. onclick change image with url
    By mdrawdy in forum JavaScript
    Replies: 4
    Last Post: 10-01-2007, 05:07 PM
  5. onClick to change image but with a variable passed
    By Stig in forum Looking for such a script or service
    Replies: 3
    Last Post: 07-14-2007, 12:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •