Script Categories

Messages >>> Random Number.

Pass a range of numbers to this JavaScript function and it will return a random number within that range. For example, passing the range of [1, 158] would return a number such as 37, 141, 18, etc.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">      
/* Visit for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);

document.write("<b>Random number in [1, 158]:  ");
//  End -->

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.

Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).