js Select下拉列表框進(jìn)行多選、移除、交換內(nèi)容的具體實(shí)現(xiàn)方法
更新時(shí)間:2013年08月13日 16:37:46 作者:
我們經(jīng)常會(huì)看到很多的網(wǎng)站會(huì)看到有下拉列表的內(nèi)容進(jìn)行直接增加與移除,下面我來介紹一款js Select下拉列表框進(jìn)行多選、移除、交換內(nèi)容實(shí)例
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<span class='wp_keywordlink_affiliate'><a href="tag/html" title="查看 html 中的全部文章" target="_blank">html</a></span>4/loose.dtd">
<<span class='wp_keywordlink_affiliate'><a href="tag/html" title="查看 html 中的全部文章" target="_blank">html</a></span>>
<head>
<title>Select下拉列表框進(jìn)行多選、移除、交換內(nèi)容</title>
<meta http-equiv="Content-Type" content="text/<span class='wp_keywordlink_affiliate'><a href="tag/html" title="查看 html 中的全部文章" target="_blank">html</a></span>; charset=gb2312">
</head>
<body style="font-size:12px">
<form name="form1" method="post" action="">
<table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150"><table width="150" border="0" cellpadding="1" cellspacing="1" bgcolor="#CAFAFC">
<tr>
<td height="25" background="wp-content/uploads/2012/05/79760-772704496-8.gif" bgcolor="#FFFFFF"> 請(qǐng)選擇:</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><select name="sel_place1" size="6" multiple id="sel_place1" style="width:100px " >
<option value="sel1">江蘇省</option>
<option value="sel2">廣東省</option>
<option value="sel3">河南省</option>
<option value="sel4">吉林省</option>
<option value="sel5">浙江省</option>
</select></td>
</tr>
</table></td>
<td width="80" align="center" valign="bottom"><input name="sure1" type="button" id="sure1"
onClick="allsel(document.form1.sel_place2,document.form1.sel_place1);" value="<<">
<input name="sure2" type="button" id="sure2"
onClick="allsel(document.form1.sel_place1,document.form1.sel_place2);" value=">>" align="center" height="2"></td>
<td width="150"><table width="150" border="0" cellpadding="1" cellspacing="1" bgcolor="#CAFAFC">
<tr>
<td height="25" background="wp-content/uploads/2012/05/79760-772704496-8.gif" bgcolor="#FFFFFF"> 請(qǐng)選擇:</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><select name="sel_place2" size="6" multiple id="sel_place2" style="width:100px ">
</select></td>
</tr>
</table></td>
</tr>
</table>
</form>
<script language="javascript">
function allsel(n1,n2)
{
while(n1.selectedIndex!=-1)
{
var indx=n1.selectedIndex;
var t=n1.options[indx].text;
n2.options.add(new Option(t));
n1.remove(indx);
}
}
</script>
</body>
</html></td>
</tr>
</table>
您可能感興趣的文章:
相關(guān)文章
uploadify在Firefox下丟失session問題的解決方法
在用uploadify上傳插件時(shí)遇到了一個(gè)問題,在讀session時(shí)認(rèn)為沒有權(quán)限而被攔截了,后來在后臺(tái)打印登錄時(shí)產(chǎn)生session的id和上傳時(shí)讀取session的id,解決方法如下,感興趣的朋友可以了解下2013-08-08
JavaScript實(shí)現(xiàn)獲取年月日時(shí)間的方法總結(jié)
這篇文章主要為大家學(xué)習(xí)介紹了JavaScript如何實(shí)現(xiàn)獲取年月日以及各種格式的時(shí)間,文中的示例代碼簡潔易懂,感興趣的小伙伴可以了解一下2023-08-08
JavaScript實(shí)現(xiàn)表格表單的隨機(jī)選擇和簡單的隨機(jī)點(diǎn)名
本文主要介紹了JavaScript實(shí)現(xiàn)表格表單的隨機(jī)選擇和簡單的隨機(jī)點(diǎn)名,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08

