1. ## random number generating

how can i create a random number that is in between multiple variables. for example 0-10, 100-110.

it can be in between either of the two options but no greater or less

2. Code:
```If you have multiple ranges, put them in an array:
var arr=[[0,5],[100,105]];

get a random index of the array:

r=arr[Math.floor(Math.random()*arr.length)],
min=r[0], max=r[1];

then generate the random number from the selected range.

Math.floor(Math.random()*(max-min+1)+min)```

3. This code is working in Konqueror 4.5.5 and Firefox 4.0b9
Code:
```
<script type="text/javascript">

var A =[ [0,10], [100,110]];
var t = String(new Date().getTime()).slice(this.length-2);

var r = A[Math.floor(Math.random()*A.length)];
var min=r[0];
var max=r[1];
var mod = max - min + 1;
var kalan = Number(t) % mod;
var result = min + kalan;

</script>```

4. without using Math.random
Code:
```
<script type="text/javascript">

var A =[ [0,10], [100,110]];
var s = String(new Date().getTime());
var d = s.slice(this.length-1);
var t=  s.slice(this.length-2);

var r = A[ Number(d) % A.length];
var min=r[0];
var max=r[1];
var mod = max - min + 1;
var kalan = Number(t) % mod;
var result = min + kalan;

</script>```

#### Posting Permissions

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