Page 1 of 1

Really stressing me out... please help...

Posted: Tue Nov 02, 2010 7:59 pm
by Andrew2010
I can't find any help with this. Ok, here's what I need:

I have a page called woodland.php, where I want a random image in a set position generated on page load. I have this done with HTML, but with that I have to make a page for every image! Seen here:
<script language="JavaScript">

<!-- Begin
var howMany = 10; // max number of items listed below
var page = new Array(howMany+1);

page[0]="earwig.htm";
page[1]="mantis.htm";
page[2]="";
page[3]="";
page[4]="";
page[5]="";
page[6]="firefly.htm";
page[7]="";
page[8]="";
page[9]="ant.htm";
page[10]="";


function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</script>


I place the image I want to load on each page, seen here:
<a href="capture.php"><img style="POSITION: absolute; TOP: 244px; LEFT: 410px" border =0 hspace=0 src ="images/insects/Earwig.png" width=70 height=33 ></a>
Is there a way to generate these images on page load, in the same way as above, but without creating a new page for EVERY image?! There has to be a way to do this with PHP. Once again, I need to generate these images on woodland.php and not having to make a page for every image I generate. This way, users can't find these images with a address.

PLEASE HELP!

Re: Really stressing me out... please help...

Posted: Wed Nov 03, 2010 2:04 am
by cpetercarter
You have got a large part of the way there. But instead of using your javascript to load the page with the right image, use it to change the src attribute of the img tag. (Better - put no src attribute in your html, use javascript to add it).