多選列表框動(dòng)態(tài)添加,移動(dòng),刪除,全選等操作的簡(jiǎn)單實(shí)例
<%
dim a
a = split(Request.Form("sourceList"),",")
Response.Write "Source:" & Request.Form("sourceList") & ubound(a) & "<br>Object:" & Request.Form("objectList") & "<br>"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
<STYLE type=text/css>
.bgsubleft {
BACKGROUND-POSITION: center bottom; BACKGROUND-IMAGE: url(images/bgleft.gif); BACKGROUND-REPEAT: repeat-x
}
.bgsubleftn {
BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: url(images/bgleftn.gif); BACKGROUND-REPEAT: no-repeat
}
</STYLE>
<script language="JavaScript" type="text/JavaScript">
function addSelectedList()
{
var objSource = form1.sourceList;
var objObject = form1.objectList;
var sourcelen = objSource.length ;
for(var i=0;i<sourcelen;i++){
if (objSource.options[i].selected){
if (!checkExist(objObject,objSource.options[i].value)){
addtolist(objObject,objSource.options[i].text,objSource.options[i].value);
}
}
}
}
function addAllList()
{
var objSource = form1.sourceList;
var objObject = form1.objectList;
var sourcelen = objSource.length ;
for(var i=0;i<sourcelen;i++){
if (!checkExist(objObject,objSource.options[i].value)){
addtolist(objObject,objSource.options[i].text,objSource.options[i].value);
}
}
}
function removeSelectedList(noRemoveValue)
{
var objObject = form1.objectList;
for (var i=0;i<objObject.length;i++){
if (objObject.options[i].selected && objObject.options[i].value != noRemoveValue)
{
objObject.options.remove(i);
removeList(noRemoveValue);break;
}
}
}
function removeAllList(noRemoveValue)
{
var objObject = form1.objectList;
var objLen = objObject.length;
for (var i=0;i<objLen;i++){
if ( objObject.options[i].value != noRemoveValue){
objObject.options.remove(i);
removeAllList(noRemoveValue);break;
}
}
}
function selectedAll(obj)
{
for (var i=0;i<obj.length;i++){
obj.options[i].selected = true;
}
}
function checkExist(obj,value)
{
var isExist = false;
for (var i=0;i<obj.length;i++){
if (obj.options[i].value == value){
isExist = true;
break;
}
}
return isExist;
}
function addtolist(obj,value,label){
obj.add(new Option(value,label));
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="form1" action="temp.asp" method="post">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><select name="sourceList" size="10" multiple id="sourceList" style="width:150">
<option value="a">1</option>
<option value="b">2</option>
<option value="c">3</option>
<%
for i = 6 to 20
Response.Write("<option value=""" & i+200 & """>" & i+200 & "</option>" & vbcrlf)
Next
%>
</select></td>
<td><input name="add" type="button" id="add" value="Add" onclick="addSelectedList()" style="width:100"><br>
<input name="add" type="button" id="add" value="Add all" onclick="addAllList()" style="width:100"><br>
<input name="add" type="button" id="add" value="Remove" onclick="removeSelectedList('a')" style="width:100"><br>
<input name="add" type="button" id="add" value="Remove all" onclick="removeAllList('a')" style="width:100">
<input name="add" type="button" id="add" value="Select all" onclick="selectedAll(form1.objectList)" style="width:100"></td>
<td><select name="objectList" size="10" multiple id="objectList" style="width:150">
<option value="a">1</option>
<option value="d">4</option>
<option value="e">5</option>
<%
for i = 6 to 20
Response.Write("<option value=""" & i & """>" & i & "</option>" & vbcrlf)
Next
%>
</select></td>
</tr>
<tr>
<td></td>
<td><input name="subm" type="submit" value="Submit" style="width:100"></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
相關(guān)文章
自己寫(xiě)了一個(gè)展開(kāi)和收起的多更能型的js效果
展開(kāi)和收起這樣的效果想必大家早就眼熟了吧,利用閑暇時(shí)間用js寫(xiě)了一個(gè)具體功能:當(dāng)自己處于全部顯示的時(shí)候,點(diǎn)擊自己的收起,自己收起等等感興趣的你可以參考下哈2013-03-03JavaScript中訪問(wèn)id對(duì)象 屬性的方式訪問(wèn)屬性(實(shí)例代碼)
下面小編就為大家?guī)?lái)一篇JavaScript中訪問(wèn)id對(duì)象 屬性的方式訪問(wèn)屬性(實(shí)例代碼)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10JavaScript下通過(guò)的XMLHttpRequest發(fā)送請(qǐng)求的代碼
JavaScript下通過(guò)的XMLHttpRequest發(fā)送請(qǐng)求的代碼,需要的朋友可以參考下。2011-06-06JavaScript+css+HTML實(shí)現(xiàn)移動(dòng)端輪播圖(含源碼)
這篇文章主要介紹了JavaScript+css+HTML實(shí)現(xiàn)移動(dòng)端輪播圖并含源碼的分享,需要的小伙伴可以參考一下,希望對(duì)你有所幫助2022-01-01基于Javascript開(kāi)發(fā)連連看游戲小程序
這篇文章主要介紹了基于Java開(kāi)發(fā)連連看游戲小程序,連連看是在有限的時(shí)間內(nèi),只要把所有能連接的相同圖案,兩個(gè)一對(duì)地找出來(lái),消除全部就成功了,文中提供了解決思路和部分實(shí)現(xiàn)代碼,需要的朋友可以參考下2023-03-03BootStrap Table 分頁(yè)后重新搜索問(wèn)題的解決辦法
這篇文章主要介紹了BootStrap Table 分頁(yè)后重新搜索問(wèn)題的解決辦法,自定義搜索且有分頁(yè)功能,比如搜索產(chǎn)品名的功能。小編給大家?guī)?lái)了關(guān)鍵代碼,非常不錯(cuò),需要的朋友可以參考下2016-08-08layui將table轉(zhuǎn)化表單顯示的方法(即table.render轉(zhuǎn)為表單展示)
今天小編就為大家分享一篇layui將table轉(zhuǎn)化表單顯示的方法(即table.render轉(zhuǎn)為表單展示),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09