Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2013
    Posts
    21
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Smile 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
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    What do you mean swap, like change the order of items?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Jul 2013
    Posts
    21
    Thanks
    9
    Thanked 0 Times in 0 Posts
    yes, i think the whole thing needs to be converted to php.
    i want to load/read file as array
    be able to swap images(arrays)
    then save/overwrite the file to view changes

  • #4
    New Coder
    Join Date
    Jul 2013
    Posts
    21
    Thanks
    9
    Thanked 0 Times in 0 Posts
    or should i be storing my images into database or something

  • #5
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,918
    Thanks
    15
    Thanked 227 Times in 227 Posts
    I was writing a page that allows you to drag links into a textarea and make another list of links, but you could just as easily build an array, or do whatever you want with them.
    Here it is:
    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
    <style type="text/css">
    body 
    {
    background:#003300;width:960px;margin: 0 auto;
    font-size:24px;color:white;font-family:Verdana;
    margin-top: 50px;
    }
    a {color: white;}
    </style>
    </head>
    <body>
    <?php
    // This makes an array of the links.
    if(isset($_POST['mylinks'])) 
    {
    $links $_POST['mylinks'];
    $links str_replace('http','|http',$links);
    $lnk explode("|",$links);
    //Do what you want with the links here.
    for($cnt=1;$cnt<count($lnk);$cnt++)
    {
    echo 
    '<a href="'.$lnk[$cnt].'">File: '.$cnt.'</a><br />
    '
    ;
    }
    }
    ?>
    <form id="mydata" method="post" action="#">
    <textarea name="mylinks" cols=80 rows=20 ></textarea>
    <input type="submit" value="Send Links" />
    </form>
    </body>
    </html>
    Just drag them in, in the order that you want them to appear, first will be first, last will be last.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.


  •  

    Posting Permissions

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