help finding complex cookie script for my boardgame site
My boardgame site is ALMOST done!
But... I still need a save option (for all the various form fields throughout the site). I've been trying to implement the cookie ability but am having all kinds of problems. The script needs to:
- Save all form elements to cookie with ONE button.
- Load all variables back into fields with ONE button.
PROBLEM 1: there is more than 1 form on my page, the scripts I've seen only save variables from a single form (multiple save buttons would be needed - one for each form). I need to be able to save ALL forms with just ONE button (same with loading).
PROBLEM 2: the scripts I've seen only deal with simple text-box variables. what would the code look like to get other types of form elements (ie. radio buttons, checkboxes, etc.
PROBLEM 3: my site has moveable game pieces that need their x & y coordinates saved to and loaded from the cookie as well. Haven't a clue how to approach this one.
As this is my last hurdle to overcome on the site I've been working on for a few years, my brain has fizzled from too much work. So any and all help would be exuberantly appreciated.
ps. my forms are split up as follows:
TOKENS, UPGRADES, ETC. (moveable pieces)(not a form obviously)
PLAYER TURN (radio buttons - form 1)
CURRENT CASH (textbox - form 2)
PROPERTY OWNERSHIP (form 3)
PROPERTY UPGRADES (form 3 also)
COLLECTABLE DRAW CARDS (checkboxes, ownership drop-downs - form 4)
Thanks in advance :)
Not hard at all. BUT...
Are you aware that cookies are limited to 4KB in size?
It's quite possible that what you are asking for would exceed that size.
If you are willing to live with only more modern browsers being able to use your site, you could use Local Storage, instead.
p.s.: Saving state is easier than restoring it. But neither is a major task.
p.s.: This will all be a lot easier if you don't have any duplicated field names, even in different <form>s.
And I do have to ask why you think you need separate <form>s on the page. Generally, I recommend a single <form>, with the <form> tag right after <body> and the </form> right before </body>.
Is there something magic about the separate <form>s that implies how they are used by, say, server-side code?
To clarify, my site is meant to only be played OFFLINE. :(
I created it to playtest a boardgame I designed so as to avoid unnecessary pre-production costs. Never meant for it to get online, though... maybe some day.
I WISH I could get it online, but my coding skills, though fairly good in some areas, are lacking in others. (Just adding a DOCTYPE declaration to my page screws up a bunch of formatting.
The game plays like a combo of Monopoly and RISK, with touches of concepts from other games as well. It is WAY bigger than Monopoly, WAY nicer to look at, is WAY more fun to play, has a better theme, and can take many nights to finish (or can end at any time). The replayability is HUGE, with the ability to shuffle and distribute the gameboard squares in any order on the gameboard.
My boardgame is fully polished now (well, the playtesting site is, minus the save feature). The game itself is just in need of playtesting.
It really is an unbelievable game and concept that will hopefully soon rock the boardgame world and take Monopoly off the market (everybody loves Monopoly, but I figured a way to make it 1000 times better).
I will look into the HTML5 starage thing (mentioned on another forum), never heard of it before, but if it requires money to use or a server to run it through, than I can't take that route.
I'll check back later.
Thanks all :)
No, no...LocalStorage is built into HTML5. Just as much a part of the system as are cookies.
But now comes the question: If adding a DOCTYPE screws up your formatting, how will you then use <!DOCTYPE html> to specify HTML5??
|All times are GMT +1. The time now is 10:25 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.