# Switching Stylesheets

**URL:** <https://forum.kirupa.com/t/switching-stylesheets/78618>\
**Category:** programming\
**Created:** [February 6, 2005, 5:27pm UTC](https://forum.kirupa.com/t/switching-stylesheets/78618 "2005-02-06T17:27:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trundrumbalind](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trundrumbalind/32/696_2.png) [@trundrumbalind](https://forum.kirupa.com/u/trundrumbalind)\
**Post date:** [February 6, 2005, 5:27pm UTC](https://forum.kirupa.com/t/switching-stylesheets/78618/1 "2005-02-06T17:27:01Z")

</div>

OK, I have an \*\*inline \*\*stylesheet and one styles the background image of a table cell. It looks like this:

```auto
	.maincell2 {
		background-image: url('<?php echo $randomimage ?>');
		height: 319px;
		width: 263px;
		border: solid 1px #000000;
		border-width: 0px 1px 1px 0px;
		padding-left: 8px;
		padding-bottom: 8px;
	}

```

By the way, at the top, I have the following:

```auto
$randomimage = "bgimages/bgimage_" . rand(1,10) . ".jpg";

```

So basically, the background image of the “maincell2” cell is random.

Now, what would a function look like that, when called, would change this stylesheet so it would run the randomizing code again and change the stylesheet to the new background-image?

Any help would be much appreciated,  
Dave
