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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Getting multiple values from List Box

    Hi,

    I have a one LIST BOX , in which a user has option to select multiple values. I want that if user select 3 values from LIST BOX, then my program print all these three values on the submission of the form

    plz help me in in the code

    bye

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    example:

    Code:
    <form action="file.php" method="post">
      <select name="myselect[]" id="myselect" multiple="multiple">
        <option value="option_1">Option 1</option>
        <option value="option_2">Option 2</option>
        <option value="option_3">Option 3</option>
        <option value="option_4">Option 4</option>
      </select>
      <input type="submit" value="Submit" />
    </form>
    and the PHP:

    PHP Code:
    <?php

    $all_selected_values 
    '';
    foreach(
    $_POST['myselect'] as $value)
    {
      
    $all_selected_values .= $value."\r\n";
    }

    ?>
    Does that help?


  •  

    Posting Permissions

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