www.webdeveloper.com
Results 1 to 2 of 2

Thread: loading array then saving new array

  1. #1
    Join Date
    Jul 2013
    Posts
    3

    Wink loading array then saving new array

    need to convert this i think to php, this has the functions i need to image swap the photos but wont save the changes.
    i think i need to store all the src in a file to display images as an array then when i make a change with image swap to automatically save the array or have update button to save new array.
    here is the code i currently have as an example just with function
    any help will be greatly appreciated

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>Swap demo</title>
    
    <style type="text/css">
    #GALLERY td {
    height: 200px; width: 200px;
    text-align: center;
    vertical-align: middle;
    }
    #GALLERY td img, #GALLERY td img.normal {
    border: solid white 5px;
    }
    #GALLERY td img.highlighted {
    border: solid red 5px;
    }
    </style>
    
    </head>
    <body>
      <table id="GALLERY">
      <tr>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/Puppy In Basket.jpg"      alt="Dogs"/>          
          </td>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/BabyIndy.jpg" alt="Dogs"/>          
          </td>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/HarlequinDane.jpg" alt="Dogs"/>          
          </td>
      </tr>
      <tr>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/Pug.jpg" alt="Dogs"/>          
          </td>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/Wagner-edit1.jpg" alt="Dogs"/>          
          </td>
          <td>
              <img src="http://www.clearviewarts.com/thumbnails/CanusAngelicus.jpg" alt="Dogs"/>          
          </td>
      </tr>
      </table>
    
    <script type="text/javascript">
    var pix = document.getElementById("GALLERY").getElementsByTagName("img");
    for ( var p = 0; p < pix.length; ++p )
    {
    pix[p].onclick = picclick;
    }
    
    var firstImage = null;
    function picclick( )
    {
    // to cancel a swap, click on first image again:
    if ( firstImage == this ) 
    {
        this.className = "normal";
        firstImage = null;
        return;
    }
    // is this first image clicked on?
    if ( firstImage == null )
    {
        // yes
        firstImage = this;
        this.className = "highlighted";
        return; // nothing more to do
    }
    // aha! second image clicked on, so do swap
    firstImage.className = "normal";
    var temp = this.src;
    this.src = firstImage.src;
    firstImage.src = temp;
    firstImage = null;
    
    }
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,226
    You might get a better response if you posted in the Javascript forum.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles