Thread: JS cookie

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    JS cookie


    Hey guys, I need help with this simple thing, I am new to js but not entirely to web design.

    I have task to make two values like this

    javascript Code:
     
    document.cookie =
      'partizan=pogodak; expires=Sat; path=/'
     
      document.cookie =
      'zvezda=promasaj; expires=Sat; path=/'


    And now html thing, two buttons or drop down menu with this two values, partizan and zvezda

    After person click on partizan for example cookie should be stored with value pogodak and next time person come to page, it will get message pogodak and redirect to some other page, not important atm, and cookies should expire on first Saturday.

    I know is not big deal, but I find lots of code with not needed code for me, and when I delete those that is not of use to me, whole script is broken, so I need to make it simple like this. Thanks in advance.
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,128
    Rep Power
    4304
    There's a specific format needed for dates.

    I recommend you read this article: http://www.quirksmode.org/js/cookies.html

    You'll probably want to read some of the articles on forms and events as well:
    http://www.quirksmode.org/js/forms.html
    http://www.quirksmode.org/js/contents.html#events
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0
    I did read that, but I still cant figure out how to connect js with html in dropdown menu

    do I have to make for each option new js page that will create cookie and new function, or I can simple put like option and inside same line, code for storing cookie

IMN logo majestic logo threadwatch logo seochat tools logo