473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Random Background image for a table - IMAGE ARRAY

What I am trying to accomplish is to have the background image of a table change every time a page is reloaded/refreshed. I have tried many different scripts and non of them have worked for me. I have a total of four images at the moment that will be used in this array.

Any and all help would be greatly appreciated.


Thanks in advance,
May 15 '07 #1
2 6117
iam_clint
1,208 Expert 1GB
Example
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. window.onload = function() {
  3. var bimages = ["img1.gif", "img2.gif", "img3.gif", "img4.gif"];
  4. var rand=Math.floor(Math.random()*4);
  5. newImage = "url(backgrounds/"+bimages[rand]+")";
  6. document.getElementById('table').style.backgroundImage = newImage;
  7. }
  8. </script>
  9. <table id="table" border=1 width=200 height=200>
  10. <tr><td align="center">Hi</td></tr>
  11. </table>
  12.  
May 15 '07 #2
Clint,


Thank you so much that worked perfect.


Regards,


jemedina74


Example
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. window.onload = function() {
  3. var bimages = ["img1.gif", "img2.gif", "img3.gif", "img4.gif"];
  4. var rand=Math.floor(Math.random()*4);
  5. newImage = "url(backgrounds/"+bimages[rand]+")";
  6. document.getElementById('table').style.backgroundImage = newImage;
  7. }
  8. </script>
  9. <table id="table" border=1 width=200 height=200>
  10. <tr><td align="center">Hi</td></tr>
  11. </table>
  12.  
May 15 '07 #3

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

Similar topics

3
by: MediaDesign | last post by:
so there's the problem: my text links have background images and when I put links around images on my page, they too get the background image treatment which I do not...I have tried several...
13
by: Giggle Girl | last post by:
Hi there, I need to use a background image in a TR that does NOT restart everytime it hits a TD. Can it be done? Specifically, if you set a background image for an entier table, now mater how...
6
by: Luis Arvayo | last post by:
Hello, I am trying to convert a jpeg image stored in a PictureBox to a byte array in order to later save it to a database, but I get this error : "Generic Error in GDI+". The source code is...
2
by: Deasun | last post by:
Heres the code I have: Dim objTheStream As MemoryStream = New MemoryStream Dim objPhoto As Image = pic_PhotoToUpload.Image() With objPhoto .Save(objTheStream,...
0
by: aparth | last post by:
I've been trying and failing to create an image map that contains a tiled background image underneath the main image. My image map is 600px in height. I want the main image (img_bottom.jpg) to...
1
by: Jim in Arizona | last post by:
I created a public application based variable not within any procedure, like so: Partial Class lobbytimes_lobbytimes Inherits System.Web.UI.Page Public BackgroundImage As String Protected...
3
by: schof | last post by:
I am using the following code to call a random background image to be displayed on the far right hand side of the page ... <script type="text/javascript"> function random(n) { return...
0
by: peerraghu | last post by:
hi how to create image table in the SQL database, i wrote small querry just look at these CREATE TABLE Product_image1 ( IDENTITY (1, 1) NOT NULL , NOT NULL , (50), ...
1
by: anmcafresher | last post by:
Hi Guys, I am working with an option where I do want to print a background image without enabling the "Print Background Color and Image" in the IE. I do want to get this image printed on each...
2
by: zceef05 | last post by:
I want to know how we could convert an image into an array of numbers. Furthemore coud you pleezzzzz tell me how we cud rotate this matrix ( please note te commands of java shud be rotating the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.