Advanced Search

Results 1 to 4 of 4

Thread: randomizer

  1. #1
    Join Date
    Jul 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default randomizer

    hi
    i'm looking for a script that will allow me to randomize a block of code on a page. specifically, i have a page that has a div container that is set to display an image and a quote below it. i have many of these image/quote blocks for the page and i'd like to have them randomly display on visit or reload. i've done a few searches for scripts to take care of this, but haven't been able to find anything. any help would be appreciated, thanks much.

  2. #2
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    Do you have the blocks of text/images in an array? If so you could use a random number code to pick one randomly.

    Code:
    Math.randomNum = function (min,max) {
    	var random = function (maxN) {
    		return Math.floor (Math.random () * maxN);
    	}
    	return random (max - min) + min;
    }
    That would be code for a random number. (There's probably better though)

  3. #3
    Join Date
    Jan 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hi

    Please try the attched file

  4. #4
    Join Date
    Jul 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    right, i know about random image generators. so how would you change this to randomly generate blocks of images AND text? say for instance these were the blocks of code that needed to be randomly generated:

    <div id="image"><img src="image1.gif" /></div>
    <div class="textHd">Header Text 1</div>
    <div class="textBdy">Body Text 1</div>


    <div id="image"><img src="image2.gif" /></div>
    <div class="textHd">Header Text 2</div>
    <div class="textBdy">Body Text 2/div>

    <div id="image"><img src="image3.gif" /></div>
    <div class="textHd">Header Text 3</div>
    <div class="textBdy">Body Text 3</div>

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
  •