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

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0

    Question Help me with JS cookies


    hi all!

    i am learning how to use cookies recently, and my project is:


    To make a task list in HTML(max. 2) and use cookies to track the user if and see is the user completed the task.

    If the task is successfully completed, there should be an indication on the website to move on the next task.

    after all tasks all completed, there should be a submit button and by pressing it, the information will be recorded that this user completed the task, and the info will be send to me.

    E.X:
    a task is that someone has to click on the link on the page, which will direct him to a YouTube video and the cookies will track if user has finished watching the video and automatically indicate on the screen that the task has been completed and move on to the next task.

    Is that possible, I really need a volunteer who is able to help this kid.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    When the user clicks on the link to view the youtube video, you can set a cookie to indicate that they clicked on the link. It is not possible to use cookies to check if they finished watching the video on youtube.

    Here is an extensive article on how cookies work and how to manipulate them with JavaScript: http://www.quirksmode.org/js/cookies.html

    As far as your particular problem goes, it will probably be easiest to give each task a numeric ID and then store a list of completed task IDs in the cookie (separated by something like a comma). You can either mark the task as completed when the user clicks on a link, or you can have a checkbox or button to mark the task as completed.

    You will need to read from the cookie when rendering the page in order to determine which tasks are completed, and you will need to write to the cookie when a user marks a task as completed.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by E-Oreo
    When the user clicks on the link to view the youtube video, you can set a cookie to indicate that they clicked on the link. It is not possible to use cookies to check if they finished watching the video on youtube.

    Here is an extensive article on how cookies work and how to manipulate them with JavaScript: http://www.quirksmode.org/js/cookies.html

    As far as your particular problem goes, it will probably be easiest to give each task a numeric ID and then store a list of completed task IDs in the cookie (separated by something like a comma). You can either mark the task as completed when the user clicks on a link, or you can have a checkbox or button to mark the task as completed.

    You will need to read from the cookie when rendering the page in order to determine which tasks are completed, and you will need to write to the cookie when a user marks a task as completed.
    Thanks for helping me,

    So Lets make it a little less complicated,

    If i create a <p> tag i have to give it a id, like
    Code:
    <p id="001">test</p>
    then i would create a cookie, how would i set it up to see if the <p> tag is click on?

IMN logo majestic logo threadwatch logo seochat tools logo