日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

将select中的项从一个移动到另一个select中

發布時間:2023/12/9 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 将select中的项从一个移动到另一个select中 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
??? <title>將select中的項互相移動(添加或移除)</title>
?<script language="javascript" type="text/javascript">

??function execSelectGroup(tagContentID, flag)
??{
????? var obj = document.getElementById(tagContentID).getElementsByTagName("select");
????? var i, j, moveFrom, moveTo;
????? if(flag == 1 || flag == 2)????????????????? //全部添加或添加
????? {
????????? moveFrom = obj[0];????????????????????? //availableGroups???????????
????????? moveTo = obj[1];??????????????????????? //selectedGroups
????? }
????? else if(flag == 3 || flag == 4)???????????? //刪除或全部刪除
????? {
????????? moveFrom = obj[1];
????????? moveTo = obj[0];
????? }
?????
????? for(i = 0; i < moveFrom.length;)
????? {
????????? var op = moveFrom.options[i];
????????? if(flag == 1 || flag == 4 || moveFrom.options[i].selected)? //全部添加或移除
????????? {
????????????? var newOption = document.createElement("option");
????????????? newOption.value = op.value;
????????????? newOption.text = op.text;
????????????? moveTo.options.add(newOption);????? //增加一個
????????????? moveFrom.remove(i);
????????? }
???????????? else
???????????????? i++;
????? }
??}
?</script>
</head>

<body>
?<div id="addAccount_tagContent3" class="tagContent">
??<table width="600" border="0" cellspacing="0" cellpadding="5">
??? <tr>
???<td>
?????? <fieldset>
??????? <legend>組信息</legend>
?????<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
?????? <tr>
??????<td style="width:40%;text-align:center;">
???????可選組
??????</td>
??????<td>&nbsp;
???????
??????</td>
??????<td style="width:40%;text-align:center;">
???????已選組
??????</td>
?????? </tr>
?????? <tr>
??????<td style="width:40%;text-align:center;">
???????<select name="availableGroups" size="10" style="width:120px;" multiple>
????????<option value="1">可選組一</option>
????????<option value="2">可選組二</option>
????????<option value="3">可選組三</option>
???????</select>
??????</td>
??????<td align="center">
???????<input type="button" name="selectAll" value=">>" style="width:35px; height:18px; margin-bottom:2px;" title="全部添加" οnclick="execSelectGroup('addAccount_tagContent3', 1)" /><br/>
???????<input type="button" name="addThis" value=">" style="width:35px; height:18px; margin-bottom:2px;" title="添加" οnclick="execSelectGroup('addAccount_tagContent3', 2)" /><br/>
???????<input type="button" name="deleteThis" value="<" style="width:35px; height:18px; margin-bottom:2px;" title="刪除" οnclick="execSelectGroup('addAccount_tagContent3', 3)" /><br/>
???????<input type="button" name="deleteAll" value="<<" style="width:35px; height:18px; margin-bottom:2px;" title="全部刪除" οnclick="execSelectGroup('addAccount_tagContent3', 4)" /><br/>
??????</td>
??????<td style="width:40%;text-align:center;">
???????<select name="selectedGroups" size="10" style="width:120px;" multiple>
????????<option value="1">已選組一</option>
????????<option value="2">已選組二</option>
????????<option value="3">已選組三</option>
????????<option value="4">已選組四</option>
???????</select>
??????</td>
?????? </tr>
?????</table>
?????? </fieldset>
???</td>
??? </tr>
??</table>
?</div>
?<div id="editAccount_tagContent3" class="tagContent">
???? <table width="600" border="0" cellspacing="0" cellpadding="5">
?????? <tr>
????? <td>
????????? <fieldset>
?????????? <legend>組信息</legend>
??????? <table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
????????? <tr>
???????? <td style="width:40%;text-align:center;">
????????? 可選組
???????? </td>
???????? <td>&nbsp;
??? ??????
???????? </td>
???????? <td style="width:40%;text-align:center;">
????????? 已選組
???????? </td>
????????? </tr>
????????? <tr>
???????? <td style="width:40%;text-align:center;">
????????? <select name="availableGroups" size="10" style="width:120px;" multiple>
?????????? <option value="1">可選組一</option>
?????????? <option value="2">可選組二</option>
?????????? <option value="3">可選組三</option>
?????????? <option value="4">可選組四</option>
?????????? <option value="5">可選組五</option>
????????? </select>
???????? </td>
???????? <td align="center">
????????? <input type="button" name="selectAll" value=">>" style="width:35px; height:18px; margin-bottom:2px;" title="全部添加" οnclick="execSelectGroup('editAccount_tagContent3', 1)" /><br>
????????? <input type="button" name="addThis" value=">" style="width:35px; height:18px; margin-bottom:2px;" title="添加" οnclick="execSelectGroup('editAccount_tagContent3', 2)" /><br>
????????? <input type="button" name="deleteThis" value="<" style="width:35px; height:18px; margin-bottom:2px;" title="刪除" οnclick="execSelectGroup('editAccount_tagContent3', 3)" /><br>
????????? <input type="button" name="deleteAll" value="<<" style="width:35px; height:18px; margin-bottom:2px;" title="全部刪除" οnclick="execSelectGroup('editAccount_tagContent3', 4)" /><br>
???????? </td>
???????? <td style="width:40%;text-align:center;">
????????? <select name="selectedGroups" size="10" style="width:120px;" multiple>
?????????? <option value="1">已選組一</option>
?????????? <option value="2">已選組二</option>
????????? </select>
???????? </td>
????????? </tr>
??????? </table>
????????? </fieldset>
????? </td>
?????? </tr>
???? </table>
??? </div>
</body>
</html>

總結

以上是生活随笔為你收集整理的将select中的项从一个移动到另一个select中的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。