开发者

Any technique on generate ID on js?

I want to make a WYSIWYG editor on web, and it supports multiple users for inputting data, but while the user is editing, many divs will create during the process, and each div should have an unique id to write in database, and use JS to generate. But the question is.... the id should be unique, how can I ensure the js code is unique, seems the js is execute in the client side, it may not occur....(the user may modify it using firebugs), al开发者_开发问答so, the other client is editing the same document also, they may also use the same id, and the system will have a problem.....

Any ideas on that?


Give each client a large unique number range.


Consider maintaining a global variable based on a session variable/application variable and increment it or else you can use random number / datetime or both of them together.

Maybe like this :

id = Application variable + Session variable + (increment as per requirement)...

That will serve in both ways to give a unique solution.. In fact with known increment, your server can keep track of all the changes you make on client.

hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜