Multiple select list in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekhs
    New Member
    • Jul 2006
    • 2

    Multiple select list in PHP

    Hi all

    I have more than one multiple select lists in a page. Something like this

    <tr>

    <td>
    <select NAME="StrainLis t" ID="StrainList " SIZE="5" multiple="multi ple" style="width: 150px">
    <?
    for ($i=0; $i < $rows; $i++)
    {
    mysql_data_seek ($result,$i);
    $qryrslt = mysql_fetch_arr ay($result);
    echo "<option value='$qryrslt[0]'>$qryrslt[0]</option>";
    }

    ?>
    </select></td>
    <td>
    <input TYPE="BUTTON" VALUE="->" ONCLICK="addIt( 'StrainList', 'PickList');"></input>
    <br>
    <input TYPE="BUTTON" VALUE="<-" ONCLICK="delIt( 'StraintList', 'PickList');"></input></td>
    <td>
    <select NAME="PickList[]" ID="PickList" SIZE="5" multiple="multi ple" style="width: 150px">
    </select></td>
    </tr>

    <tr>
    <td ALIGN="left">&n bsp;</td>
    <td></td>
    <td ALIGN="right">& nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" ALIGN="left"><d iv align="center"> <font size="-1" face="Arial, Helvetica, sans-serif">Hydrolys is of chromogenic substrates </font> </div></td>
    </tr>
    <tr>
    <td>
    <select NAME="SelectLis tn" ID="SelectListn " SIZE="5" multiple="multi ple" style="width: 150px">
    <?
    for ($i=0; $i < $rows3; $i++)
    {
    mysql_data_seek ($result3,$i);
    $qryrslt = mysql_fetch_arr ay($result3);
    echo "<option value='$qryrslt[0]'>$qryrslt[0]</option>";
    }

    ?>
    </select></td>
    <td>
    <input TYPE="BUTTON" VALUE="->" ONCLICK="addIt( 'SelectListn', 'PickListn');"> </input>
    <br>
    <input TYPE="BUTTON" VALUE="<-" ONCLICK="delIt( 'SelectListn', 'PickListn');"> </input></td>
    <td>
    <select NAME="PickListn[]" ID="PickListn" SIZE="5" multiple="multi ple" style="width: 150px">
    </select></td>
    </tr>
    <tr>

    when i am trying to porcess my form in php, only the first picklis tis getting detected. The second one is not. Any help would be greatly appreciated
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    If your select list is multiple, suffix square brackets to the name. That will submit an array of all the selected values to your target script.
    [HTML]<select NAME="StrainList[]" ID="StrainList " SIZE="5" multiple="multi ple" style="width: 150px">[/HTML]

    Comment

    Working...