How to Generate Random Numbers on Every Time page loads using Jquery ?
In my previous post I had shown you “Cross site ajax call”. Today I have interesting topic. I am going to write about " Generating random numbers using jquery on every page refresh. "
To follow us in twitter :
https://twitter.com/#!/myinfoplace1
Get Random Numbers on Page load using jquery
=====================================
Load jquery.js file into your html file and put this code inside your script tag-
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("jquery", "1.2.6");
</script>
<script type="text/javascript">
google.load("jquery", "1.2.6");
</script>
Or
<script type="text/javascript">
$(function () {
var numMin = '345';
var numMax = '26654'; var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1; var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow); if ((IsNumeric(
numMin)
&& (IsNumeric(numMax )) && (parseFloat(
numMin
) <= parseFloat(numMax )) && (
numMin
!= '') && (numMax != '')) { $("#randomnumber").val('DTKT'+numRand); }});
function IsNumeric(n){ return !isNaN(n);}
</script>
<input type="text" name="txtTicketId" id="randomnumber" />
Thats it you have done. Now every time you refresh your page you will be able to get random generated number with string. You can set your min to max range for random numbers as I mentioned variable like numMin and numMax.
Hope This post will be helpful to you. Keep visiting here and If you would like to post anything Technical article then please write me. I will post for you. This day's I am little bit busy with my work, so only not able to keep active post every week. I hope you all like my posts. Please do share with your friends. And Join my network in facebook, linkedin etc.
Thank you all. All the best.
You also can join my group for latest technology updates in below link,To join in LinkedIn :
http://www.linkedin.com/groups?about=&gid=4300612
http://www.linkedin.com/groups?about=&gid=4300612
To Join in Facebook:
http://www.facebook.com/pages/Open-source-Web-Developers-Programmers/275124762559654
http://www.facebook.com/pages/Open-source-Web-Developers-Programmers/275124762559654
To Join in Google+ :
To follow us in twitter :
https://twitter.com/#!/myinfoplace1
No comments:
Post a Comment