title: Making a simple javascript Image gallery
body: <p>I'm trying to make a very simple Image gallery. Most of the design is already complete (used JQuery)...but now I'm trying to think out the logic it takes to get the images to change. For this part I was thinking I would just use javaScript instead of Jquery just to keep it simple. I'm not too familiar with the javaScript syntax but this is my attempt to get started. Is this a feasible way to create an image gallery? I know making the images the background isn't a great idea, but for testing purposes I don't feel like cropping images -- so setting the image as the background trims the images to fit.</p>
  <p>I was also trying to think about how to set the ImageCnt to zero initially... Can an onload function be used to set the ImageCnt to 0 when the page loads? Can a var be passed into next()? If so, I could pass the current ImageCnt from the onClick to the function.</p>
  <p>PS. I've omitted a lot of code to keep it simple to read, but I can provide more if it's necessary.</p>
  <p>Thanks! here's my code:</p>
  <h1>Javascript</h1>
  <pre><code>&lt;script&gt;
    function next()
    {
      var myImage= new Array(); 
      myImage[0]=&quot;penguins.jpg&quot;;       
      myImage[1]=&quot;desert.jpg&quot;;
      myImage[2]=&quot;jellyfish.jpg&quot;;
      myImage[3]=&quot;flower.jpg&quot;; 
  
      ImageCnt++;
  
      document.getElementById(&quot;whiteBox&quot;).style.background = 'url(myImage[ImageCnt])';
    }
  &lt;/script&gt;
  </code></pre>
  <h1>html</h1>
  <pre><code>&lt;a href=&quot;#&quot; onclick=&quot;next()&quot;&gt;&lt;img src=&quot;next.png&quot;/&gt;&lt;/a&gt;
  </code></pre>