DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Posts
    3

    script for swapping images (not mouseover)

    I want to create a puzzle with 6 image slices, however i don't understand the script that i want to create. It has to switch positions with the one clicked before and after. Any help would be great thanks.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    What code do you have so far?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    <html>
    <head>
    <title>image swapping</title>
    <script>
    function remember(mypackage){
    pictureclicked=mypackage
    }
    function swap(){
    memory=pictureclicked.src
    pictureclicked.src=sw.src
    sw.src=memory
    }




    </script>
    </head>

    <body>


    <table>
    <tr>
    <td><img id="zero" src="pic1.jpg" onclick="remember(zero)" width="80" height="100"></td>
    <td><img id="one" src="pic2.jpg" onclick="remember(one)" width="80" height="100"></td>
    <td><img id="two" src="pic3.jpg" onclick="remember(two)" width="80" height="100"></td>
    <td><img id="three" src="pic4.jpg" onclick="remember(three)" width="80" height="100"></td>
    <td><img id="four" src="pic5.jpg" onclick="remember(four)" width="80" height="100"></td>
    <td><img id="five" src="pic6.jpg" onclick="remember(five)" width="80" height="100"></td>
    </tr>
    <tr>
    <td colspan="4" align="center">
    swap with<img name="sw"
    src="pic1.jpg"
    width="50"onclick="swap(swap)"></td>
    </tr>
    </table>
    </body>
    </html>
    i just want to get rid of this piece of code so it can be able to switch from 2 pics inside the puzzle instead of going back to the "memory" one
    <td colspan="4" align="center">
    swap with<img name="sw"
    src="pic1.jpg"
    width="50"onclick="swap(swap)"></td>

  4. #4
    Join Date
    Apr 2011
    Posts
    3
    i figured it out. but does anyone know how to make a script that counts the number clicks made to arrange the scrambled puzzle?

Similar Threads

  1. Replies: 2
    Last Post: 08-23-2005, 02:19 PM
  2. Replies: 3
    Last Post: 08-20-2002, 12:14 AM
  3. script for two rotating sets of images on same page
    By dom in forum Architecture and Design
    Replies: 0
    Last Post: 04-06-2002, 01:36 AM
  4. Replies: 0
    Last Post: 10-29-2001, 01:55 PM
  5. Re: We don't get round trips...
    By Avron Polakow in forum Web
    Replies: 1
    Last Post: 11-06-2000, 02:09 PM

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links