Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    55
    Thanks
    26
    Thanked 0 Times in 0 Posts

    help finding complex cookie script for my boardgame site

    Hi all.

    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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,015
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,015
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    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?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Mindphaser (02-13-2013)

  • #4
    New Coder
    Join Date
    Oct 2012
    Posts
    55
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    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?
    lol about seperate forms. I am just a hobby web designer who has never been able to take an official course.

    I WISH I had used 1 form to begin with. I know alot more about forms now than I did 5 years ago when I started my site. My site is soooo bloody big now that to go in and change all the form names through the dozens of external javascripts could be a real pain. But that might be the route to go.

    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.

    It is a shame too because my site is quite cool. Tonnes of javascript. Hundres of movable pieces. Rewards system. Complex drawcard system that uses 3 decks of 150 cards each, which can be collected and combined and redeemed for cash (ie. RISK)

    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

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,015
    Thanks
    79
    Thanked 4,436 Times in 4,401 Posts
    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??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •