By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,385 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,385 IT Pros & Developers. It's quick & easy.

links to graphics

P: 1
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.length

function init()
{
var lookup = randomlist(slideshowlength)

for (i = 0; i < slideshowlength; i++)
{
document.getElementById('cell' + i).innerHTML="<p>" + slideshow[lookup[i]] + "</p>"
}
}

function searcharray(input, 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(result, val))
{
val = randomnumber(n)
}
result[k] = val
}

return result
}

function randomnumber(n)
{
return Math.floor(n * Math.random())
}

window.onload=init

</script>
Sep 11 '06 #1
Share this Question
Share on Google+
1 Reply


rameshsambu
P: 15
hi bssp


could you please show me the code where you actually use the script? I mean the code portion where you would like to see the actual images.

Seems like I probably can help


-Ramesh
Nov 2 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.