title: Use of setTimeout - how to pass parameters?
body: <p>I am trying to develop a slideshow with a pause between slides. So I'm trying to use the setTimeout statement as shown below. This is written to swap 2.jpg for 1.jpg with a pause of 10 seconds on clicking the button. But it does now work. Can anyone help me. Thanks.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  var t;
  function swap(newImage) {
    var fileName=newImage.toString()+".jpg"
    document.slideshow.src=fileName
    t=setTimeout("swap()",10000)
  }
  &lt;/script&gt;
  &lt;/head&gt;  
  &lt;body&gt; 
    &lt;img name="slideshow" src="1.jpg" width="450" height="335" /&gt;
    &lt;br /&gt;&lt;br /&gt;
    &lt;input type="button" onClick="swap('2')" value="Change image" /&gt; 
    &lt;br /&gt;&lt;br /&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>