Loading ...

Generate Random Number In JavaScript | CodeAsp.Net

Generate Random Number In JavaScript

 /5
0 (0votes)

In this Blog I will explain how we can gernerate random number.

Example -

 

<HTML>
<HEAD>
<SCRIPT type="text/javascript">
function GenerateRandomNo()
{
var _date=new Date()
var ran_num=(_date.getSeconds())%10
var ran_num=ran_num+1
alert(ran_num)
}
</SCRIPT>
</HEAD>
<BODY>
<form>
<INPUT TYPE="button"
VALUE="Generate Number from 1 to 10"
onClick="GenerateRandomNo()">
</FORM>
</BODY>
</HTML>

 

Happy Coding:)

Mohit Kumar

Comments (no comments yet)

Top Posts