国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

js簡(jiǎn)單實(shí)現(xiàn)Select互換數(shù)據(jù)的方法

2019-11-20 11:48:57
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了js簡(jiǎn)單實(shí)現(xiàn)Select互換數(shù)據(jù)的方法。分享給大家供大家參考。具體如下:

這里基于javascript實(shí)現(xiàn)兩個(gè)Select互換數(shù)據(jù),簡(jiǎn)單實(shí)用,大家都見(jiàn)到過(guò)的,不多說(shuō)了,即使手頭暫時(shí)用不上,收藏起來(lái),以備后用。

運(yùn)行效果如下圖所示:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-select-cha-data-codes/

具體代碼如下:

<title>兩個(gè)Select互換數(shù)據(jù),簡(jiǎn)單實(shí)用</title><script language="JavaScript">var MainSel = null;var SlaveSel = null;var Item_org = new Array();function DoAdd(){ var this_sel = null; for(var i=0;i<MainSel.options.length;i++){  this_sel = MainSel.options[i];  if(this_sel.selected){   SlaveSel.appendChild(this_sel);   i--;  } } sort_Main(SlaveSel);}function DoDel(){ var this_sel = null; for(var i=0;i<SlaveSel.options.length;i++){  this_sel = SlaveSel.options[i];  if(this_sel.selected){   MainSel.appendChild(this_sel);   i--;  } } sort_Main(MainSel);}function sort_Main(the_Sel){ var this_sel = null; for(var i=0;i<Item_org.length;i++){  for(var j=0;j<the_Sel.options.length;j++){   this_sel = the_Sel.options[j];   if(this_sel.value==Item_org[i][0] && this_sel.text==Item_org[i][1]){    the_Sel.appendChild(this_sel);   }  } }}window.onload=function(){ MainSel = select1; SlaveSel = select2; MainSel.ondblclick=DoAdd; SlaveSel.ondblclick=DoDel; var this_sel = null; for(var i=0;i<MainSel.options.length;i++){  this_sel = MainSel.options[i];  Item_org.push(new Array(this_sel.value,this_sel.text)); }}</script><table width="300" border="0" cellspacing="0" cellpDoAdding="0" align="center"> <tr> <td width="45%" align="center"> <select id="select1" size="5" multiple style="width: 100px">  <option value="111">111</option>  <option value="222">222</option>  <option value="333">333</option>  <option value="444">444</option>  <option value="555">555</option>  <option value="666">666</option>  </select>  </td> <td width="10%" align="center"> <input name="DoAdd" type="button" value=">>" onClick="DoAdd()"><br> <input name="DoDel" type="button" value="<<" onClick="DoDel()"> </td> <td width="45%" align="center"> <select id="select2" size="5" multiple style="width: 100px"> </select> </td> </tr></table>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 元谋县| 乐清市| 南陵县| 武义县| 巴东县| 渑池县| 华坪县| 柳江县| 定襄县| 越西县| 宁国市| 台江县| 舒城县| 德保县| 乐亭县| 宜阳县| 云浮市| 黄石市| 拉孜县| 南丹县| 肇州县| 蒙阴县| 福清市| 锦屏县| 舒兰市| 贡山| 钟山县| 板桥市| 宜城市| 龙陵县| 丰城市| 固安县| 新郑市| 镇康县| 蓬溪县| 富宁县| 修水县| 辽阳市| 富蕴县| 汶上县| 永清县|