473,441 Members | 2,068 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,441 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 6119
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.