Results 1 to 2 of 2

Thread: loading array then saving new array

  1. #1
    Join Date
    Jul 2013

    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

    <!DOCTYPE html>
    <html lang="en">
    <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;
      <table id="GALLERY">
              <img src="http://www.clearviewarts.com/thumbnails/Puppy In Basket.jpg"      alt="Dogs"/>          
              <img src="http://www.clearviewarts.com/thumbnails/BabyIndy.jpg" alt="Dogs"/>          
              <img src="http://www.clearviewarts.com/thumbnails/HarlequinDane.jpg" alt="Dogs"/>          
              <img src="http://www.clearviewarts.com/thumbnails/Pug.jpg" alt="Dogs"/>          
              <img src="http://www.clearviewarts.com/thumbnails/Wagner-edit1.jpg" alt="Dogs"/>          
              <img src="http://www.clearviewarts.com/thumbnails/CanusAngelicus.jpg" alt="Dogs"/>          
    <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;
    // 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;

  2. #2
    Join Date
    Mar 2007
    You might get a better response if you posted in the Javascript forum.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

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