SMF For Free Support Forum
Signup For Free Forum
October 06, 2008, 08:36:46 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: Random Selection  (Read 710 times)
0 Members and 1 Guest are viewing this topic.
trevix
SMF For Free Sr. Member
*
Offline Offline

Posts: 303



View Profile WWW
« on: November 18, 2007, 06:18:42 am »

Simple script, took me a while to work it out just right.  I used it on my sytlesheet generator.


<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
var op_text = new Array ();
op_text[0] = "what ever you want, html is ok 2";
op_text[1] = "some more stuff";
op_text[2] = "guess what...";
op_text[3] = "more stuff";
var i = Math.round(3*Math.random());

document.write(op_text[i]);

//-->
</SCRIPT>


you can delete options and add as many as you want, upon refresh it will display a diff option.
after you got the all the options take the last one (in this case 3) and plug it into "var i = Math.round(3*Math.random());" replace the three with the last option so it know how many there are.

Your first option is always 0

Combine it with mr.css refresh script for fun lol
« Last Edit: November 18, 2007, 08:54:50 pm by trevix » Logged


Ad Machine - Free advertising and tips on how to promote your board.
Crasy
Global Moderator
*
Offline Offline

Posts: 3309


I Approve of this Message


View Profile WWW
« Reply #1 on: November 23, 2007, 04:16:20 pm »

You should note to people that putting and " in the script will mess with it.

So something like <img src="imageurl"> will mess with it. Right? I think.
Logged

LaundryLady
Global Moderator
*
Offline Offline

Posts: 3046



View Profile WWW
« Reply #2 on: November 23, 2007, 04:40:48 pm »

Possibly using ' instead of this " would be ok.  I know it is in Agent Moose's stuff.  Of course I have no idea what this code does.  I am unable to see the concept of it in my head.
Logged

Coreeeey
SMF For Free Sr. Member
*
Offline Offline

Posts: 311



View Profile WWW
« Reply #3 on: November 23, 2007, 05:24:45 pm »

Possibly using ' instead of this " would be ok.  I know it is in Agent Moose's stuff.  Of course I have no idea what this code does.  I am unable to see the concept of it in my head.

I think, its supposed to show a new text everytime the page is refreshed. So you could visit the site and it would show text 1 and then later you could go back and it would show a different text (2, 3, 4, 0, and so on)
Logged

trevix
SMF For Free Sr. Member
*
Offline Offline

Posts: 303



View Profile WWW
« Reply #4 on: November 23, 2007, 06:28:49 pm »

nope its random, and yes you need ' not " in html
Logged


Ad Machine - Free advertising and tips on how to promote your board.


Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.275 seconds with 18 queries.