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 http://www.yaldex.com/ 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]:  ");
document.write(getRandomNum(1,158)+'</b>');
//  End -->
</script>

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!).




©