开发者

Using jQuery to store client side Cookies for input fields, checkboxes, etc?

I am not hoping for a full source code, but i will be grateful if someone shed some light on this.

Basically the situation is:

  1. The user visits the web page, where he can filter the content based on the values of some selectboxes and checkboxes, etc.) I've done that part already to update the content dynamically based on the returned value or ID/name of field.

  2. Now if the user Refresh the page, the filters will be lost. I refer to filters h开发者_开发技巧ere, the checkboxes he checked, unchecked etc. No he will redo it again and thats not practical.

  3. I wish to know if there is an easy way to save what the user checks as filters in cookies or something so that the form remains the same from his last visit. But I want to accomplish this without any server side work.

Can anyone shed some light or show me some steps or plugins that can allow me to do this?


You can just use plain JavaScript, or use a jQuery cookie plugin.

The plugin makes it a little friendlier to set them. In JavaScript, you do...

document.cookie = 'key=value; expires=Mon, 29 Nov 2010 23:40:00 UTC; path=/'

... to set them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜