I created a javascript function for generate unique random number. for this function i take object of date and call funciton of getTime() which return milliseconds since 970/01/01 and i also add some random numeric value between 0 to 999 from make it Random.
code snips is as
[script language="javascript"]
function UniqRanDomNumber()
{
var d = new Date();
var randomnumber = Math.floor(Math.random()*1001);
var randomnumber = d.getTime() + randomnumber;
//alert(randomnumber.toString().length);
//alert(randomnumber.toString().substring(6,13)); // If we want to remove right side number whihc are prefixed
document.getElementById("lbl").innerHTML = randomnumber;
return false;
}
[/script]
lbl is id of label where we want to show the uniq random nubmer.
Thanks
HelpOnDesk Team
No comments:
Post a Comment