Hello all,
I have the following script added to a webpage im working on and i cannot get the graphics to display. Could someone tell me whats wrong please.
The idea is that each time the page loads the 9 graphics appear in a different position in the 3 by 3 grid chosen randomly. At the moment only the filename appears.
<script type="text/javascript">
var slideshow = new Array ()
slideshow[0] = "new1.jpg"
slideshow[1] = "new2.jpg"
slideshow[2] = "new3.jpg"
slideshow[3] = "new4.jpg"
slideshow[4] = "new5.jpg"
slideshow[5] = "new6.jpg"
slideshow[6] = "new7.jpg"
slideshow[7] = "new8.jpg"
slideshow[8] = "new9.jpg"
var slideshowlength = slideshow.lengt h
function init()
{
var lookup = randomlist(slid eshowlength)
for (i = 0; i < slideshowlength ; i++)
{
document.getEle mentById('cell' + i).innerHTML="< p>" + slideshow[lookup[i]] + "</p>"
}
}
function searcharray(inp ut, num)
{
var returnval = false
for (j = 0; j < input.length; j++)
{
if (input[j] == num)
{
returnval = true
}
}
return returnval
}
function randomlist(n)
{
var result = new Array()
for (k = 0; k < n; k++)
{
var val = randomnumber(n)
while (searcharray(re sult, val))
{
val = randomnumber(n)
}
result[k] = val
}
return result
}
function randomnumber(n)
{
return Math.floor(n * Math.random())
}
window.onload=i nit
</script>
I have the following script added to a webpage im working on and i cannot get the graphics to display. Could someone tell me whats wrong please.
The idea is that each time the page loads the 9 graphics appear in a different position in the 3 by 3 grid chosen randomly. At the moment only the filename appears.
<script type="text/javascript">
var slideshow = new Array ()
slideshow[0] = "new1.jpg"
slideshow[1] = "new2.jpg"
slideshow[2] = "new3.jpg"
slideshow[3] = "new4.jpg"
slideshow[4] = "new5.jpg"
slideshow[5] = "new6.jpg"
slideshow[6] = "new7.jpg"
slideshow[7] = "new8.jpg"
slideshow[8] = "new9.jpg"
var slideshowlength = slideshow.lengt h
function init()
{
var lookup = randomlist(slid eshowlength)
for (i = 0; i < slideshowlength ; i++)
{
document.getEle mentById('cell' + i).innerHTML="< p>" + slideshow[lookup[i]] + "</p>"
}
}
function searcharray(inp ut, num)
{
var returnval = false
for (j = 0; j < input.length; j++)
{
if (input[j] == num)
{
returnval = true
}
}
return returnval
}
function randomlist(n)
{
var result = new Array()
for (k = 0; k < n; k++)
{
var val = randomnumber(n)
while (searcharray(re sult, val))
{
val = randomnumber(n)
}
result[k] = val
}
return result
}
function randomnumber(n)
{
return Math.floor(n * Math.random())
}
window.onload=i nit
</script>
Comment