I have a multi-select listbox created (and processed via PHP). As such I named it with braces in the name, like:

<select multiple size="10" name="sel2[]"> </select>

However, I can't get javascript to reference the listbox when I name it that way (I need the javascript to dynamically insert/delete items from the list).

I had originally named the list "multilist" without the braces and the javascript worked fine, and it let me multi-select, but php would only see the last item selected. Based on hints I read elsewhere, to enable php to process the multi-selections into an array, I renamed the list with the braces [] but now the javascript simply does not work -- it will not insert data into the list.

Is their any trick to the control naming I need to know?


Code that i m using is :
// ====================================
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{
var selLength = theSel.length;
if(selLength>0)
{
theSel.options[theIndex] = null;
}
}

function moveOptions(theSelFrom, theSelTo)
{
var selLength = theSelFrom.length;
var selectedText = new Array();
var selectedValues = new Array();
var selectedCount = 0;
var i;

// Find the selected Options in reverse order
// and delete them from the 'from' Select.
for(i=selLength-1; i>=0; i--)
{
if(theSelFrom.options[i].selected)
{
selectedText[selectedCount] = theSelFrom.options[i].text;
selectedValues[selectedCount] = theSelFrom.options[i].value;
deleteOption(theSelFrom, i);
selectedCount++;
}
}

// Add the selected text/values in reverse order.
// This will add the Options to the 'to' Select
// in the same order as they were in the 'from' Select.
for(i=selectedCount-1; i>=0; i--)
{
addOption(theSelTo, selectedText[i], selectedValues[i]);
}

if(NS4) history.go(0);
}
// ==============================================
This is html control

<table width="99%" border="0">
<tr>
<td width="45%">
<select multiple size="10" name="sel1">
<option value="155101">Auktioner</option>
<option value="132901">Barn &amp; Baby</option>
<option value="132901-100140113">-Baby p&aring; vej</option>
<option value="132901-108501">--Babyt&oslash;j</option>
<option value="132901-100328023">--Babyudstyr</option>
</select>
</td>
<td width="9%">
<input onclick="moveOptions(this.form.sel1, this.form.sel2);" type=button value=" &raquo; "><br/>
<input onclick="moveOptions(this.form.sel2, this.form.sel1);" type=button value=" &laquo; ">
</td>
<td width="45%">
<select multiple size="10" name="sel2[]"> </select>
</td>
</tr>
</table>
// ====================================