Click to See Complete Forum and Search --> : Unique Id Generation
rameshk
05-08-2003, 03:54 AM
i want 2 know how to generate a unique id using javascript .
i have 2 follow 2 things while generating a unique id .
1.) it should be in short range (1 to 32,767)
2.) without refering to previous generated id's i have to generate the other id's
Do any one have idea or clue to do this ???
Regards ,
K.Ramesh
Charles
05-08-2003, 04:51 AM
I can satisfy 2) but not 1).
var uniqueId = new Date().getTime()
rameshk
05-08-2003, 04:59 AM
Hi ,
thanks . i am also trying using date object only . but i need 2 satisfy both condns ...
currentTime.getSeconds() will always return the unique id within a miniute (0-59 - With in short range)
currentTime.getSeconds()+""+currentTime.getMinutes()) will always return a unique id within a hour .(0-5959 With in short range)
currentTime.getSeconds()+""+currentTime.getMinutes()+""++currentTime.getHours()) will always return a unique id within a day .(0-595923 NOT With in short range)
so here only my problem arises . if 3rd condn satisfies i will b done . in this way i dont need to store the id's and refer it back . can u help me something similar to this .
waiting for ur reply
Thanks & Regards ,
Ramesh
khalidali63
05-08-2003, 05:40 AM
Sounds like a tough call,I have a feeling that other then storing the values in an array you will find it hard to get a solution