Closed Thread Icon

Topic awaiting preservation: looking for a script... Pages that link to <a href="https://ozoneasylum.com/backlink?for=7910" title="Pages that link to Topic awaiting preservation: looking for a script..." rel="nofollow" >Topic awaiting preservation: looking for a script...\

 
Author Thread
lotiss
Paranoid (IV) Inmate

From: San Diego CA USA
Insane since: Mar 2000

posted posted 11-02-2001 11:38


That changes an image/chooses a random image on refresh.

I know that I have seen it around somewhere, but can't think of where... can anyone help me?

Thanks alot in advance!

Nimraw
Paranoid (IV) Inmate

From: Styx
Insane since: Sep 2000

posted posted 11-02-2001 12:54

I've used this one earlier. No doubt someone will post a smarter better one, but what the..

code:
<Script Language ="JavaScript">

function RandomNumber()
{
var today = new Date();
var num= Math.abs(Math.sin(today.getTime()/1000));
return num;
}

function RandomGraphics()
{
var x = RandomNumber();

if (x > .77) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .66) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .55) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .44) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .33) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .22) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > .11) {document.write("<img src='image here' align=center border=0>"); return; }
if (x > 0) {document.write("<img src='image here' align=center border=0>"); return; }
}


//End Script

</SCRIPT>



[This message has been edited by Nimraw (edited 11-02-2001).]

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 11-02-2001 13:19

the date-trick is cool, nimraw.

but JS also features Math.random() which returns a pseudo-random number between 0.0 and 1.0.
(we all know that something like random doesnt really exists on a computer )

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-02-2001 13:25

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Nimraw
Paranoid (IV) Inmate

From: Styx
Insane since: Sep 2000

posted posted 11-02-2001 13:27

Gruble: Yeah, I know, but when I tested that some numbers were favored.

I usually use a function that checks clock seconds and and control the pseudo-random from that aspect. The user should statisticly load the page with even distributíon over the second span. (or so i figger)



[This message has been edited by Nimraw (edited 11-02-2001).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-02-2001 13:40

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

lotiss
Paranoid (IV) Inmate

From: San Diego CA USA
Insane since: Mar 2000

posted posted 11-03-2001 00:54

Thanks you guys, I really appreciate your responses! I am a little busy with something else at the moment, but will try out your solutions a little later this evening.

To answer the question:

does it mean you want a generic image to be always there on FIRST LOAD,
and then a random image on any subsequent REFRESH of that page?
What I would like to do is have a set folder of images that are the same size, and the placement on the page is the same, but everytime the page is accessed/refreshed, a new/different/random image is shown. Does that make sense? As in I have image a, b, c, etc, but A does not have to be there the first time it loads, but everytime it is refreshed a new, random image is displayed.


Ini, it is not that I don't give a f*** about coding, I really respect those who can, but I am just not one of them! I have tried, really I have, but I just don't even get it! (It must be the blonde hair!) But I can copy and paste, and mess around a little, trial and error modifications and such.... but no, I am not a math person!

So once again, thank you Nimraw, Grumble, and Ini!

[This message has been edited by lotiss (edited 11-03-2001).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-03-2001 14:00

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Blook
Paranoid (IV) Inmate

From: Utah, USA
Insane since: Apr 2000

posted posted 11-08-2001 00:20

How cool is this?

Just today I wanted to find a random image script, so I wander down the hall to the DHTML/Javascript Cell and paydirt! There is already a topic with the answer to my question. I love this place.


These eyes have walls.

Blook
Paranoid (IV) Inmate

From: Utah, USA
Insane since: Apr 2000

posted posted 11-08-2001 03:41

I'm having trouble with your script InI.

The only image it will produce is image10.gif. I tested it out by changing n=10 to n=5 and it would then only produce image5.gif. Am I doing something wrong?


These eyes have walls.

lotiss
Paranoid (IV) Inmate

From: San Diego CA USA
Insane since: Mar 2000

posted posted 11-08-2001 11:02


.... And it's double-cool, 'cause I was comming in to say thanks it worked! Here is the fix Blook:

Change:

code:
document.write("<img src='image"+n+".gif' border=0>");



to:

code:
document.write("<img src='image"+r+".gif' border=0>");



change the +n+ to +r+ (I think Ini was testing me!!)

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-08-2001 11:11

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Blook
Paranoid (IV) Inmate

From: Utah, USA
Insane since: Apr 2000

posted posted 11-09-2001 00:55

So does n=x where x=the number of images you have?

Seems like my hunch was right. No need to answer. Thanks for the help everyone.


These eyes have walls.

[This message has been edited by Blook (edited 11-09-2001).]

« BackwardsOnwards »

Show Forum Drop Down Menu