SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Abbotsford
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remember when checkbox is "checked"

    I have an HTML page with many checkboxes, and i want the page to remember which boxes are checked and those that arent, so that when the user comes back, it looks the way it did before.

    Obviously to do this we need to place a cookie, but how do i present the state of the checkbox after the cookie has been queried??

    Any advise/code would be greatly appreciated. I have been using JavaScript to place and query the cookies so far.

  2. #2
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai, India
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use Checked property of checkbox to check it by default.
    <input type=checkbox name="chk_way" checked value="right" id = "id_way">

    will display a checkbnox which id checked.
    you can achieve this by the javassdcript also
    id_way.checked=true;

    if you find the value in the cookie then make it true. else make it false.
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Abbotsford
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vikrantkorde
    you can use Checked property of checkbox to check it by default.
    <input type=checkbox name="chk_way" checked value="right" id = "id_way">

    will display a checkbnox which id checked.
    you can achieve this by the javassdcript also
    id_way.checked=true;

    if you find the value in the cookie then make it true. else make it false.
    Thanks.
    What you mean to say is that i can use id_way.checked=true; tocheck if the box is ticked or unticked.

    But my dilema is that when a box IS ticked, i want to place the cookie, and then have the form remember that in future, if this cookie exists, make that checkbox appear checked. (and if its unchecked, make it appear unchecked, but this is less important)

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ::: certified wild guess :::

  5. #5
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Abbotsford
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks Allot!!!

    Much appreciated adios!!!

    that was exactally what i was looking for, dont know why i didnt find that page earlier.

    Thanks again


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
  •