熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

JS下拉框內容左右移動效果的具體實現

2022-06-13   來源: JSP教程 
這篇文章介紹了JS下拉框內容左右移動效果的具體實現方法有需要的朋友可以參考一下   復制代碼 代碼如下:

  
<HTML>
<HEAD>
<TITLE>選擇下拉菜單</TITLE>
<META NAME="Description" CONTENT="Power by hill">
<meta httpequiv="ContentType" content="text/html; charset=utf" />
</HEAD>
<BODY>
<p>選定一項或多項然後點擊添加或移除(按住shift或ctrl可以多選)或在選擇項上雙擊進行添加和移除</p>
<form method="post" name="myform">
<table border="" width="">
<tr>
<td width="%">
<select style="WIDTH:%" multiple name="list" size="" ondblclick="moveOption(documentmyformlist documentmyformlist)">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="山東">山東</option>
<option value="安徽">安徽</option>
<option value="重慶">重慶</option>
<option value="福建">福建</option>
<option value="甘肅">甘肅</option>
<option value="廣東">廣東</option>
<option value="廣西">廣西</option>
<option value="貴州">貴州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龍江">黑龍江</option>
</select>
</td>
<td width="%" align="center">
<input type="button" value="添加" onclick="moveOption(documentmyformlist documentmyformlist)"><br/>
<br/>
<input type="button" value="刪除" onclick="moveOption(documentmyformlist documentmyformlist)">
</td>
<td width="%">
<select style="WIDTH:%" multiple name="list" size="" ondblclick="moveOption(documentmyformlist documentmyformlist)">
</select>
</td>
<td>
<button onclick="changepos(list)" type="button">上移</button>
<br/>
<button onclick="changepos(list)" type="button">下移</button>
</td>
</tr>
</table>
<input type="text" name="city" size="">
</form>
<script language="JavaScript">
function moveOption(e e){
try{
for(var i=;i<eoptionslength;i++){
if(eoptions[i]selected){
var e = eoptions[i];
eoptionsadd(new Option(etext evalue));
eremove(i);
ii=i
}
}
documentmyformcityvalue=getvalue(documentmyformlist);
}
catch(e){}
}
function getvalue(geto){
var allvalue = "";
for(var i=;i<getooptionslength;i++){
allvalue +=getooptions[i]value + "";
}
return allvalue;
}
function changepos(objindex)
{
if(index==){
if (objselectedIndex>){
objoptions(objselectedIndex)swapNode(objoptions(objselectedIndex))
}
}
else if(index==){
if (objselectedIndex<objoptionslength){
objoptions(objselectedIndex)swapNode(objoptions(objselectedIndex+))
}
}
}
</script>
</BODY>
</HTML>


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20198.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.