title: Sliding image using JavaScript
body: <p>I am trying to create a image slider, using JavaScript.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;img src="firstcar.gif" name="slide" width="100" height="56" /&gt;
  
  &lt;img src="secondcar.gif" name="slide1" width="100" height="56" /&gt;
  </code></pre>
  
  <p>Script</p>
  
  <pre><code>var image1 = new Image()
  image1.src = "firstcar.gif"
  var image2 = new Image()
  image2.src = "secondcar.gif"
  var image3 = new Image()
  image3.src = "thirdcar.gif"
  
  //variable that will increment through the images
  var step = 1
  
  function slideit() {
      //if browser does not support the image object, exit.
      if (!document.images) return
      document.images.slide.src = eval("image" + step + ".src")
      if (step &lt; 3) step++
      else step = 1
      //call function "slideit()" every 1.5 seconds
      setTimeout("slideit()", 1500)
  }
  slideit()
  </code></pre>
  
  <p>I wanted to slide two image in such a way that the upcoming image displays in the second place and slides to the first place and both the image must be inline. </p>
  
  <p>I can't find the error. Can someone help me fix it?</p>