title: Javascript: Photo Gallery with Forward/Back Button
body: <p>I'm super new to Javascript and trying to make a front and back button to move through a set of images.Below is what I'm doing but it just wont' work. I added an alert to the beginning of both functions and they worked so I know the functions are being called.
  Please help!</p>
  
  <p>HTML:
      
      
       
      </p>
  
  <p>Javascript:</p>
  
  <pre><code> var which=0;
   var photos=new Array();
    photos[0]='images/gallery/airport.jpg';
    photos[1]='images/gallery/vancouvercenter.jpg';
    photos[2]='images/gallery/translatorjudges.jpg';
    photos[3]='images/gallery/emmaplaying.jpg';
    photos[4]='images/gallery/kate.jpg';
    photos[5]='images/gallery/plushies.jpg';
    photos[6]='images/gallery/juniors.jpg';
    photos[7]='images/gallery/pikachucamera.jpg';
    photos[8]='images/gallery/dressup.jpg';
    photos[9]='images/gallery/sandiego.jpg';
    photos[10]='images/gallery/signedbox.jpg';
    photos[11]='images/gallery/top42013.jpg';
    photos[12]='images/gallery/5.JPG';
    photos[13]='images/gallery/airportplay.jpg';
    photos[14]='images/gallery/piplup.jpg';
    photos[15]='images/gallery/2.JPG';
    photos[16]='images/gallery/booze.jpg';
    photos[17]='images/gallery/dice.jpg';
    photos[18]='images/gallery/akinator.jpg';
    photos[19]='images/gallery/sleeping.jpg';
  
   function backward(){
       if (which&gt;0){
        which=which-1;
        }
       document.GetElementbyId("gallery").src=photos[which];
       }
  
    function forward(){
       if (which&lt;photos.length-1)
       {
       which=which+1;
       }
      document.GetElementbyId("gallery").src=photos[which];
      }
  </code></pre>