SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a select form field that allows you to choose multiple options (as used with the SET data type in mySQL). Here is my form:

    Code:
    Format(s): <select name="format_type" size="3" multiple>
    <option value="Compact Disc">Compact Disc
    <option value="Cassette">Cassette
    <option value="Vinyl">Vinyl</select>
    When I submit the form, $format_type will only hold the value of the last item selected. For example, if I select all 3, $format_type will hold "Vinyl" only.

    What am I doing wrong here? Is the form correct?
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to make the name of the select an array so fo your code:
    <select name="format_type[]" size="3" multiple>
    <option value="Compact Disc">Compact Disc
    <option value="Cassette">Cassette
    <option value="Vinyl">Vinyl</select>

    No the script that processes this can access it as:

    print "Your selections: <br>";
    foreach($format_type as $type) {
    print $type."<br>";
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that worked.
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!


Bookmarks

Posting Permissions

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