SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Coookies

  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    euston
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Coookies

    Help please! I need to set up a cookie that will do something similar to this:

    When a new user hits the my homepage (index.htm) a pop-up window will open automatically with a survey in it. Once the user completes the survey and hits the submit button the window goes away. Then the next time that particular user hits that same index.htm page again the cookie realises that this user has already completed that form and does not show the pop-up. If a user just closes the window without submitting, the popup will continue to open with the homepage.

    I'm very new to this, if someone could help me, I'd be very gratful

    K.

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello

    This should probably be in the javascript forum but here is a link that may help: http://javascript.internet.com/cooki...opup-once.html

    Hope it helps

    later
    Johnny

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    main_page.htm:
    Code:
    //in response to some event, like 'onload' call this function:
    <script>
    window.onload = openPopUpWithSurvey;
    
    function openPopUpWithSurvey()
    {
        var theVarIPutInTheCookie = //read cookie value;
        if (theVarIPutInTheCookie != "already completed the survey")
       {
            window.open("my_form.htm", ......);
       }
    }
    </script>
    </head>
    my_form.htm:
    Code:
    <script>
    
    function set_cookie()
    {
        //set a cookie;
    }
    
    </script>
    </head>
    <body>
    
    <form ....onsubmit='set_cookie()' ...>
    ...
    ...
    </form>
    </body>
    Cookie tutorials(setting a cookie and reading a cookie):

    http://www.elated.com/tutorials/prog...cript/cookies/
    http://www.quirksmode.org/js/cookies.html


Bookmarks

Posting Permissions

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