I have nine images that I'd like to assign as random background images in a table.
Can anybody help with that?
Thanks!
I have nine images that I'd like to assign as random background images in a table.
Can anybody help with that?
Thanks!
This uses a random number, and an array of images to show a random background color for a table.
Code:<html> <head> <script type="text/javascript"> var images = new Array("image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg","image6.jpg","image7.jpg","image8.jpg","image9.jpg") onload=function() { var rand = Math.round(Math.random()*images.length-1) table1.style.background="url('"+images[rand]+"')" } </script> </head> <body> <table id="table1"></table> </body> </html>
- Mike
Bookmarks