• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

Unique Random Numbers (ing)

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
<!-- ONE STEP TO INSTALL UNIQUE RANDOM NUMBERS:

  1.  Copy the coding into the HEAD of your HTML ********  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML ********  -->

<HEAD>

<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Barry Pranklin :: http://www.pranklin.com */

var Found=false
var Current = new Array()
var MaxValue=100 //(Example 2 is equal to: 0,1,2)
var NumUnique=3  //The number of unique numbers required
var Count=0
var Current = new Array(NumUnique)
GetUnique()

alert("The unique numbers are: " + Current[0] + ", " + Current[1] + ", and " + Current[2])
  function GetUnique()
  {
    for (i=0;Count<NumUnique;Count++)
    {
      Found=false
      var rndValue = get_random()
      var j=0
      for (j=0;j<Current.length;j++)
      {
        if (Current[j] == rndValue)
        {
          Found=true
          break
        }
      }
      if (Found)
      {
        Count--
      } else {
        Current[Count]=rndValue
      }
    }
  }
  function get_random()
  {
    var ranNum= Math.round(Math.random()*MaxValue);
    return ranNum;
  }
// End -->
</script>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  1.31 KB -->
 
Üst