Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: checkbox

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    checkbox

    Hi

    I have a page that has a bunch of check boxes with different names.
    Once the user presses the submit button another page opens.
    In that page i am trying to write code to check which check boxes are checked on the previous page and add their names to an array.

    How can i check the checkboxes from another page?
    I have to do it on another page as i am waiting for the submit action to know what boxes have been checked.

    Hope this makes some sense!
    Any help would be appreciated!

    Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Checkboxes are a little goofy because if a checkbox is not checked, it does not carry any data across the request ($_POST or $_GET). If the checkbox is checked, it comes across just like any other form input in the $_POST or $_GET array (I believe the value is the string 'on').

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If you want/need a value(whether it's on or off you could use
    Code:
    <input type="hidden" name="checkbox" value="off" />
    with the same name as the checkbox if you put it before the checkbox it will be overwritten by the checkbox if it's on, and if not you'll get "off" as the value.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Hey that's a pretty good trick, hadn't heard that one before. Nice!


  •  

    Posting Permissions

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