zoukankan
html css js c++ java
如何在客户端对ListBox进行添加删除操作
ListBox的客户端添加删除操作
<%
@ Page language
=
"
c#
"
Codebehind
=
"
WebForm1.aspx.cs
"
AutoEventWireup
=
"
false
"
Inherits
=
"
WebExample.WebForm1
"
%>
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
HTML
>
<
HEAD
>
<
title
>
WebForm1
</
title
>
<
meta
name
="GENERATOR"
Content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="CODE_LANGUAGE"
Content
="C#"
>
<
meta
name
="vs_defaultClientScript"
content
="JavaScript"
>
<
meta
name
="vs_targetSchema"
content
="http://schemas.microsoft.com/intellisense/ie5"
>
<
script
>
function
Add()
{
var
elemAll
=
document.getElementById(
"
lbAll
"
);
var
elemSel
=
document.getElementById(
"
lbSel
"
);
for
(
var
i
=
0
;i
<
elemAll.options.length;i
++
)
{
if
(elemAll.options[i].selected)
{
var
SelText
=
elemAll.options[i].innerText;
var
SelValue
=
elemAll.options[i].value;
var
Num
=
elemSel.options.length;
elemSel.options[Num]
=
new
Option(SelText,SelValue);
elemAll.options.remove(i);
i
--
;
}
}
}
function
Remove()
{
var
elemAll
=
document.getElementById(
"
lbAll
"
);
var
elemSel
=
document.getElementById(
"
lbSel
"
);
for
(
var
i
=
0
;i
<
elemSel.options.length;i
++
)
{
if
(elemSel.options[i].selected)
{
var
SelText
=
elemSel.options[i].innerText;
var
SelValue
=
elemSel.options[i].value;
var
Num
=
elemAll.options.length;
elemAll.options[Num]
=
new
Option(SelText,SelValue);
elemSel.options.remove(i);
i
--
;
}
}
}
</
script
>
</
HEAD
>
<
body
>
<
form
id
="Form1"
method
="post"
runat
="server"
>
<
TABLE
>
<
TR
>
<
TD
>
<
asp:ListBox
id
="lbAll"
runat
="server"
Width
="100px"
Height
="150px"
SelectionMode
="Multiple"
></
asp:ListBox
></
TD
>
<
TD
>
<
INPUT
id
="btnAdd"
type
="button"
value
=">>"
onclick
="Add();"
><
br
>
<
INPUT
id
="btnRemove"
type
="button"
value
="<<"
onclick
="Remove();"
>
</
TD
>
<
TD
>
<
asp:ListBox
id
="lbSel"
runat
="server"
Width
="100px"
Height
="150px"
SelectionMode
="Multiple"
></
asp:ListBox
></
TD
>
</
TR
>
</
TABLE
>
</
form
>
</
body
>
</
HTML
>
查看全文
相关阅读:
二叉树的镜像(剑指offer-18)
树的子结构(剑指offer-17)
合并两个有序链表(剑指offer-16)
OutOfMemory相关问题(内存溢出异常OOM)
Java内存区域
招银网络(一面06.29)
反转链表(剑指offer-15)
链表中倒数第k个节点(剑指offer-14)
调整数组顺序使奇数位于偶数前面(剑指offer-13)
数值的整数次方(剑指offer-12)
原文地址:https://www.cnblogs.com/newwind521/p/483816.html
最新文章
java for each实现机制
springboot log4j2
springboot freemarker
springboot actuator
springboot websocket demo
springboot jmx
springboot ConfigurationProperties
springboot first examle
jboss配置控制台日志输出导致死锁
java Runtime中maxMemory,totalMemory, freeMemory的含义
热门文章
Linux学习笔记:shell
生成并调用so动态库
Go使用protobuf
Git学习笔记
Linux安装Go
Linux安装Node.js
VSCode自定义配色方案
LiteIDE灰调配色方案
每日日报
顺时针打印矩阵(剑指offer-19)
Copyright © 2011-2022 走看看