Javascript + dynamic folders
<p>So I have a Javascript function. It is passed a folder name, say "A".
This folder contains 5 images which will be picked randomly.</p>

<p>It works well on the page load, as 1 random image appears. But I want it so that
when the image is clicked, it is randomized again with an image from the same folder. I tried to go about this with the onmousedown, but it returns a broken image link to 
file:///C:/Users/StackOverflow/Documents/Website/[object%20HTMLDivElement]/2.jpg </p>

<pre><code>    &lt;script type="text/javascript"&gt;
        // &lt;![CDATA[
        function showImage(folder){
            var randomNumber=Math.floor(Math.random()*5);
            document.write('&lt;img src="'+folder+'/'+randomNumber+'.jpg" onmousedown="showImage('+folder+')"&gt;');
        }
        //]]&gt;   
    &lt;/script&gt;
</code></pre>
