/**
*
* 移动select的部分内容,必须存在value,此函数以value为标准进行移动
*
* oSourceSel: 源列表框对象
* oTargetSel: 目的列表框对象
* oCountSel: 要进行组合成字符串的列表框
* oTargetTb: 组合字符串后放置的textbox
*/
function moveSelected(oSourceSel,oTargetSel,oCountSel,oTargetTb)
{
//alert(oSourceSel.id+oTargetSel.id+oCountSel.id+oTargetTb.id);
//建立存储value和text的缓存数组
var arrSelValue = new Array();
var arrSelText = new Array();
//此数组存贮选中的options,以value来对应
var arrValueTextRelation = new Array();
var index = 0;//用来辅助建立缓存数组
//存储源列表框中所有的数据到缓存中,并建立value和选中option的对应关系
for(var i=0; i<oSourceSel.options.length; i++)
{
if(oSourceSel.options[i].selected)
{
//存储
arrSelValue[index] = oSourceSel.options[i].value;
arrSelText[index] = oSourceSel.options[i].text;
//建立value和选中option的对应关系
arrValueTextRelation[arrSelValue[index]] = oSourceSel.options[i];
index ++;
}
}
//增加缓存的数据到目的列表框中,并删除源列表框中的对应项
for(var i=0; i<arrSelText.length; i++)
{
//增加
var oOption = document.createElement("option");
oOption.text = arrSelText[i];
oOption.value = arrSelValue[i];
oTargetSel.add(oOption);
//删除源列表框中的对应项
oSourceSel.removeChild(arrValueTextRelation[arrSelValue[i]]);
}
var str = "";
//把所有目的选择框里的内容以“;”分割放在textbox中
for(var i=0; i<oCountSel.options.length; i++)
{
str += oCountSel.options[i].value + "-" +oCountSel.options[i].text +";";
}
oTargetTb.value = str.substr(0,str.length-1);
}
</script>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<asp:ListBox ID="lbProduct" runat="server" Height="227px" Width="149px" ondblclick="moveSelected($('WzdSelector_lbProduct'),
$('WzdSelector_lbSelect'),
$('WzdSelector_lbSelect'),
$('WzdSelector_txtselect'))"></asp:ListBox></td>
<td>
<input id="Button1" type="button" value=">" onclick="moveSelected($('<%=lbProduct.ClientID %>'),
$('<%=lbSelect.ClientID%>'),
$('<%=lbSelect.ClientID%>'),
$('<%=txtselect.ClientID%>'))"
style="width: 51px" />
<br />
<input style="width: 51px" id="Button2" type="button" value="<" onclick="moveSelected($('<%=lbSelect.ClientID%>'),
$('<%=lbProduct.ClientID %>'),
$('<%=lbSelect.ClientID%>'),
$('<%=txtselect.ClientID%>'))" />
</td>
<td>
<asp:ListBox ID="lbSelect" runat="server" Height="227px" Width="149px" ondblclick="moveSelected($('WzdSelector_lbSelect'),
$('WzdSelector_lbProduct'),
$('WzdSelector_lbSelect'),
$('WzdSelector_txtselect'))">
</asp:ListBox>
<input id="txtselect" type="hidden" runat="server" />
</td>
</tr>
</table>