Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Random Object Javascript?

  1. #11
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    The ONLY code in the movie is this:

    Code:
    i = random(2)+1;
    loadMovie("swf"+i+".swf", "box_container");
    This code assumes you name all your movies to load "swfX.swf" where X is a number.

    If you want to add other movies (3, 4,583, 27, whatever) just number and name them in this way. Then change the number in the i = line to match the total number of movies.

    Code:
    i = random(4583)+1;
    loadMovie("swf"+i+".swf", "box_container");
    will choose randomly between your 4 thousand + movies.

    You can do what ever you want with this movie, the code, what ever. I don't hold any copyrights to the code I just write it

    Enjoy.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #12
    Join Date
    Mar 2007
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    W00t. Thanks, I'll use this

    You know, every time you have talked to me (the whole of 2 times! ) you have broadened my knowledge. xD

  3. #13
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    That's what we are here for

    If you really want to gain some knowledge test out my Riddle site (shameless self promotion)
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #14
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Talking

    Quote Originally Posted by Moglizorz View Post
    Quote Originally Posted by techno_race
    If you want random:
    Code:
    <script type="text/javascript">
    
    var html=new Array()
    html[0]='<button onClick=\"window.location=\'http://www.dynamicdrive.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[1]='<button onClick=\"window.location=\'http://www.javascriptkit.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[2]='<button onClick=\"window.location=\'http://www.hotscripts.com/JavaScript/Scripts_and_Programs\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[3]='<button onClick=\"window.location=\'http://www.macromedia.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[4]='<button onClick=\"window.location=\'http://channels.netscape.com/ns/browsers/default.jsp\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[5]='<button onClick=\"window.location=\'http://www.microsoft.com/windows/ie/default.htm\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[6]='<button onClick=\"window.location=\'http://www.mozilla.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[7]='<button onClick=\"window.location=\'http://www.cgiscripts.net\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[8]='<button onClick=\"window.location=\'http://www.hotscripts.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    html[9]='<button onClick=\"window.location=\'http://www.snapfiles.com\'><font style=\"text-decoration: blink\">Random Link</font></button>';
    
    var dothemath = Math.floor(Math.random()*html.length);
    document.write(html[dothemath]);
    </script>
    So for that, I would just replace from <button...to...button> on each line, and add or remove lines as I please for different random HTML strings?
    Yes. For example, if you want a green text string for one, you would change
    Code:
    html[1]="<button...>...</button>"
    to
    Code:
    html[1]="<font color=\"green\">text string</font>"

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •