wattie
06-02-2005, 09:28 PM
I wanted a module for my home page which would show a random image from a selection of my own. As I couldnt find one which suited my purpose, I read up on what to do, canibalised bits of different scripts (so appologies if you recognise something of yours here!) and came up with this:
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><b>$vba_options[portal_blockbullet] Northenders</b></span></td>
</tr>
<tr>
<td class="$getbgrow" width="100%">
<!-- Begin custom code -->
<script language="Javascript"><!--
function image() {
};
image = new image();
number = 0;
// imageArray
image[number++] = "<img src='picture1.jpg' border='1'>"
image[number++] = "<img src='picture2.jpg' border='1'>"
// Carry on adding images - as many as you want
increment = Math.floor(Math.random() * number);
document.write(image[increment]);
//-->
</script>
<!-- End custom code -->
</td>
</tr>
</table>
<br />All you do is make a template with the above code in it, put the images in your main directory, make a new module using the template and simply change picture1.jpg etc to the filename of your picture. Add as many as you like!
As I said, this is my first attempt at putting this together and was amazed when it actually worked!
Enjoy!
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><b>$vba_options[portal_blockbullet] Northenders</b></span></td>
</tr>
<tr>
<td class="$getbgrow" width="100%">
<!-- Begin custom code -->
<script language="Javascript"><!--
function image() {
};
image = new image();
number = 0;
// imageArray
image[number++] = "<img src='picture1.jpg' border='1'>"
image[number++] = "<img src='picture2.jpg' border='1'>"
// Carry on adding images - as many as you want
increment = Math.floor(Math.random() * number);
document.write(image[increment]);
//-->
</script>
<!-- End custom code -->
</td>
</tr>
</table>
<br />All you do is make a template with the above code in it, put the images in your main directory, make a new module using the template and simply change picture1.jpg etc to the filename of your picture. Add as many as you like!
As I said, this is my first attempt at putting this together and was amazed when it actually worked!
Enjoy!