时间:2021-07-01 10:21:17 帮助过:8人阅读
- <br><table cellSpacing="0" borderColorDark="#ffffff" cellPadding="3" width="460" <br>align="left" borderColorLight="#000000" border="1"> <br><tr bgColor="#cccccc"> <br><td align="center" width="180"><b>所有地区</b> <asp:HiddenField ID="HidDistrictId" runat="server" /> </td> <br><td align="center" width="60"> </td> <br><td align="center" width="180"><b>已选地区</b></td> <br></tr> <br><tr > <br><td bgcolor="#cccccc" style="height: 200px; width: 180px;" > <br><asp:listbox id="listNewEmp" runat="server" Height="200px" Width="180px" SelectionMode="Single"></asp:listbox></td> <br><td valign="top" align="center" bgcolor="#cccccc" style="height: 200px; width: 60px;"> <br><asp:Panel ID="Panel1" runat="server" Height="180px" > <br><br> <br> <br><%--<asp:Button style="WIDTH: 48px; HEIGHT: 24px; font-family:宋体" Text="选择→" ID="btnReceSendToRight" runat="server" OnClick="btnReceSendToRight_Click"/>--%> <br><INPUT type="button" value="选择→" onclick = "add('listNewEmp','listright','HidDistrictId')" Text="选择→" style="WIDTH: 48px; HEIGHT: 24px; font-family:宋体"> <br><br> <br><br> <br><INPUT type="button" value="←删除" onclick = "move('listright')" style="WIDTH: 48px; HEIGHT: 24px; font-family:宋体" Text="←删除"> <br><%--<asp:Button style="WIDTH: 48px; HEIGHT: 24px; font-family:宋体" Text="←删除" ID="btnReceSendToLeft" runat="server" OnClick="btnReceSendToLeft_Click"/>--%> <br></asp:Panel> <br></td> <br><td bgcolor="#cccccc" style="height: 200px;"> <br><asp:listbox id="listright" runat="server" Height="200px" Width="180px" SelectionMode="Multiple"></asp:listbox> <br></td> <br></tr> <br></table> <br> <br><strong>2。 javascript 部分: <br></strong><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><script language="Javascript"> <br>function add(sourlist, deslist,hidId) <br>{ //添加 <br>var objres = document.getElementById(sourlist); <br>var objsel = document.getElementById(deslist); <br>var customOptions; <br>for(var i = objres.options.length - 1 ;i >= 0;i--) <br>{ <br>if(objres.options[i].selected) <br>{ <br>customOptions = document.createElement("OPTION"); <br>customOptions.text = objres.options[i].text; <br>customOptions.value = objres.options[i].value; <br>if (objsel.options.length>0) <br>objsel.remove(objsel.options.length - 1); <br>document.getElementById(hidId).value = customOptions.value; <br>objsel.add(customOptions,0); <br>} <br>} <br>return false; <br>} <br>function move(deslist) { //删除 <br>var objres = document.getElementById(deslist); <br>objres.remove(objres.options.length - 1); <br><br>} <br></script> <br> <br><br><strong>3.。cs部分</strong> <br>存储是存 HidDistrictId.Value里的值,具体部分,用的时候再调节 <br><strong>4。 效果图:</strong> <br><img src="https://img.gxlcms.com//Uploads-s/new/2019-09-19-201919/20100526220524824.gif" border="0"></li><li> </li><li> </li></ol></pre>