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: form variables

  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form variables

    On page A i have a list of items with checkboxes, each with unique names.

    when i press the submit button, what I want is to have the following page list off what has been checked.

    Is there a way for page "b" to list all the checked off variables and ignore the unchecked variables, without actually typing out an individual command for each item?

  • #2
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    nevermind. I've decided to go about it a different way...

    <edit>

    actually though, if anyone has an answer, it would still be nice to know for days to come.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nvm. sorry

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can loop through the post-collection like this
    PHP Code:
    foreach ($_POST as $varName => $value){
        echo (
    $varName " = " $value);       

    This will print all formfield-names and there values
    But this also includes the submitbutton etc.

    If you only want the checkboxes, then you best give them all a name that start with the same x-letters (+ maybe the same value, although that isn't necessary). Like "del" or so, and then you can so something like
    PHP Code:
    foreach ($_POST as $varName => $value){
             if ((
    substr($varName,0,3) == 'del') and  ($value=='1')) {
                     echo (
    $varName " = " $value);       
             }



  •  

    Posting Permissions

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