#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    I need to process a form that has a multiple select drop down box in it ( <select name="statusselect" size="1" multiple> ). How do I process this in PHP so that I can see all of the options that the user chose?
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    See,, once you submit your multiple drop down menu.the values will be passing separated with ",".

    eg:
    <select name="statusselect" size="5" multiple>
    <option value="one">one</option>
    <option value="two">one</option>
    <option value="three">one</option>
    </select>

    the $statusselect variable will be holding a value "one,two". if i select one and two.

    You can separate this value using explode() function.

    $values=explode(",",$statusselect);
    // this returns an array of strings containing the elements.

    then you can simply play around this array
    ($values).

    Hope this may help you to sort out your problem.




    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    I've tried that but all that gets passed to my php program is the last value that I select from the multiple box. The multiple box I'm using is as follows:

    <select name="statusselect" size="1" multiple>
    <option value="All" selected>All</option>
    <option value="Cancelled">Cancelled</option>
    <option value="Completed">Completed</option>
    <option value="In Progress">In Progress</option>
    <option value="On Hold">On Hold</option>
    <option value="Proofing">Proofing</option>
    </select>

    When I select "Cancelled" and "In Progress" the statusselect variable only contain "In Progress".

    I'm using IE - does this make a difference?

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    Try treating the select variable like an array. That's how I process my lists.

    Sidenote: I had problems like you until I put the processing into a function to which the select varaible was actually passed.... e.g. pass the variable to a function before you access it.
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    Try treating the select variable like an array. That's how I process my lists.


    yes,
    you can do that .

    just try the following..

    <select name="statusselect[]" size="5" multiple>
    <option value="All" selected>All</option>
    <option value="Cancelled">Cancelled</option>
    <option value="Completed">Completed</option>
    <option value="In Progress">In Progress</option>
    <option value="On Hold">On Hold</option>
    <option value="Proofing">Proofing</option>
    </select>


    Retrieve the value like following..

    <?php

    $count=count($statusselect);

    for ($a=0; $a<$count; $a++) {
    echo $statusselect[$a];
    }
    ?>



    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    I spotted my problem - I had not included the [] characters after the variable name. Now it works like a dream.

    Thanks for your help guys.

Similar Threads

  1. MySQL output to table using phpBB
    By CCCMTech in forum PHP Development
    Replies: 0
    Last Post: February 2nd, 2004, 03:43 PM
  2. Populate multiple drop down box dependant on selection
    By maunded in forum PHP Development
    Replies: 3
    Last Post: January 21st, 2004, 01:52 AM
  3. Replies: 3
    Last Post: January 21st, 2004, 01:05 AM
  4. retrieving data from a drop down box for modifying
    By swordfishy in forum PHP Development
    Replies: 0
    Last Post: January 18th, 2004, 09:07 PM
  5. Easy! - Simple drop down box
    By JBW in forum HTML Programming
    Replies: 4
    Last Post: November 19th, 2003, 06:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo