Hi Everyone - Can you help me understand why my dynamic selection list broke after adding [] to the name of the selection list, 1stLeft[]? It was working just fine with the small chunck of javascript to setup the left and right menus but when I try to create an array with the values using the php code below it breaks it. Without the [] next to 1stLeft in the name of the selection menu it works fine. I am trying to get it working then print out the values the user selecting (or moved to the box on the right hand side)
<script type="text/javascript">
function OnTransferBtnClick(blnFromLeft)
{
var LeftListBox = document.forms[0].lstLeft;
var RightListBox = document.forms[0].lstRight;
var ListItems = new Array();
FromList = (blnFromLeft ? LeftListBox : RightListBox);
ToList = (blnFromLeft ? RightListBox : LeftListBox);
for(var i=(FromList.options.length - 1);i>=0;i--)
if(FromList.options.selected)
{
ListItems[ListItems.length] = new Option(FromList.options.text);
FromList.options = null;
}
for(var i=ListItems.length - 1;i>=0;i--)
ToList.options[ToList.options.length] = ListItems;
}
</script>
$query_getstates = "SELECT state_code, state_name FROM states";
$result_getstates = @mysql_query($query_getstates); // run the query
echo "<select name=\"lstLeft[]\" size=\"10\" multiple>";
while ($row_getstates = mysql_fetch_array($result_getstates, MYSQL_NUM)) {
echo "<option value=\"" . $row_getstates[0] . "\">" . $row_getstates[1] . "</option>";
}
<input Type="Button" Name="btnLtoR" Value=">>" onclick="OnTransferBtnClick(true)" title="Transfer Items Selected in the Left List Box to the Right List Box">
<input Type="Button" Name="btnRtoL" Value="<<" onclick="OnTransferBtnClick(false)" title="Transfer Items Selected in the Right List Box to the Left List Box">
<select name="lstRight[]" MULTIPLE size="10">
</select> </td>