SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I make checkboxes stay checked?

    Thats it basically. I have a page with checkboxes, if I check a box when I refresh the page the box is unchecked. How do I stop this happening?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Only if you somehow save the state upon checking a checkbox, you can do this. With JavaScript saving the state to a cookie, for example.

  3. #3
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you sure you mean refresh? If you mean submit then you just check to see if the checkbox was checked and if so check it!

    Code:
    <input type="checkbox" name="check" value="checked" <?php if($_POST['check'] == 'checked'): ?>checked="checked"<?php endif; ?> />


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
  •