The below Function takes two values as Arguements and provides the Random number between the Range specified . the function goes like this... <script type="text/javascript" language="javascript"> function RandomNumber(x, y) { var range = y - x + 1; alert('Random number : ' + (Math.floor(Math.random() * range) + x) + ' between ' + x + ' and ' + y); } </script> Calling the aove function by using a html button and calling it on the OnClick Event Here iam passing the Values as 0 and 10 so the range would be between 0 - 10 <input type="button" name="btnTest" title="TEST" onclick="RandomNumber(0,10)" /> Happy Coding :-)