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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    120
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Checkbox problem

    Code:
    <form>
    
    In my body, there are...<br>
    <input type=checkbox name=body value=arms>...arms<br>
    <input type=checkbox name=body value=legs>...legs<br>
    <input type=checkbox name=body value=hands>...hands<br>
    <input type=checkbox name=body value=fingers>...fingers<br>
    <input type=submit>
    
    </form><P>
    
    
    Result: <?=$_GET[body] ?>
    Alright, what I want to know is, what's the use of having the checkbox if the value will only be the last checked?
    I wonder if I made myself clear enough.
    You see, the checkbox is supossed to work so you can have multiple options selected, but that's not what it happens here...

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,303
    Thanks
    4
    Thanked 204 Times in 201 Posts
    Name them differently or, if you're going to be using PHP, name them as body[] which will make their values available in the body array when you are processing the page with PHP.
    Dave .... HostMonster for all of your hosting needs

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Location
    Troutdale, OR
    Posts
    147
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Code:
    <form>
    
    In my body, there are...<br>
    <input type=checkbox name=body value=arms>...arms<br>
    <input type=checkbox name=body value=legs>...legs<br>
    <input type=checkbox name=body value=hands>...hands<br>
    <input type=checkbox name=body value=fingers>...fingers<br>
    <input type=submit>
    
    </form><P>
    It overwrites itself.


  •  

    Posting Permissions

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