Results 1 to 2 of 2

Thread: multiselect and php

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    multiselect and php

    How can I get the value of each item selected? This only gives me the last item selected:

    PHP Code:
    if ($action == "showdata") {
        echo 
    $cats;
    } else {
        
    showform();
    }

    function 
    showform() {

    echo 
    '
    <form action="work.php?action=showdata" method="post">

        <select name="cats" size="5" multiple>
        <option value="1">Cow</option>
        <option value="2">Eats</option>
        <option value="3">Blue</option>
        <option value="4">Grass</option>
        <option value="5">Y\'all</option></select>
        
        <br><input type="Submit"></form>'
    ;
        

    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Got it:

    PHP Code:
    if ($action == "showdata") {
        echo 
    $cats;
    } else {
        
    showform();
    }

    function 
    showform() {

    echo 
    '
    <form action="work.php?action=showdata" method="post">

        <select name="[b]cats[][/b]" size="5" multiple>
        <option value="1">Cow</option>
        <option value="2">Eats</option>
        <option value="3">Blue</option>
        <option value="4">Grass</option>
        <option value="5">Y'
    all</option></select>
        
        <
    br><input type="Submit"></form>';
        

    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width