Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Need some help with a Image roating script - randomize
Old 03-11-2006, 07:59 PM Need some help with a Image roating script - randomize
Junior Talker

Posts: 4
Trades: 0
Hello all,
Im making a site for a client that wants the image under the header to roate every 10 seconds. I figured out how to do this using this script http://javascript.internet.com/misce...ge-cycler.html

I showed him this and loved it! The only thing he wants different is to have the image that first appears on each page whn clicked to be randomized. Is there anyway to change a liitle bit of code in this script to do that?

If not, any suggestions as to what i could use? Thanks in advnace for helping!
shc43 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-18-2006, 02:47 AM Re: Need some help with a Image roating script - randomize
Super Talker

Posts: 144
Trades: 0
sure... here's a randomize protocol for the Array class. just say Pix.randomize(); and it's all ready to go...

the code shows how to use it.

Code:
<script language="javascript">
  Array.prototype.randomize = function() {
    var i, r, hold;
    for (i = 0; i < this.length; i++) {
      r = Math.floor(Math.random() * this.length);
      hold = this[i];
      this[i] = this[r];
      this[r] = hold;
    }
  }
  var arr = new Array(1, 2, 3, 4, 5, 6);
  arr.randomize();
  alert(arr.join());
</script>
__________________
create.vibe

Please login or register to view this content. Registration is FREE
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Reply     « Reply to Need some help with a Image roating script - randomize
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12600 seconds with 12 queries