动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 列表框操作函数集合

作者来源: 
阅读 数 165 人次 , 2006-4-26 9:51:00 


/* 列表框互相操作函数集 */

//描述: 添加不重复列表框元素
function selAdd( srcList, dstList )
{
var selectedIndex = new Array();
var count = 0;

for ( i=0; i<srcList.options.length; i++ ){

if ( srcList.options[i].selected ){

selectedIndex[count] = i;
count ++;

}
}

for ( j=0; j<selectedIndex.length; j++ ){

k = selectedIndex[j];

if ( chkDup( srcList.options[k].value, dstList )==false ){
dstList.options.length++;
var len = dstList.options.length-1;
dstList.options[len].value = srcList.options[k].value;
dstList.options[len].text = srcList.options[k].text;
}

}

}

//描述: 删除列表框元素
function selDel( list )
{
var len = list.options.length;
var idx = 0;

while ( idx< len ){

if ( list.options[idx].selected ){
list.options.remove(idx);
len = list.options.length;
}
else{
idx ++;
}
}
}

//描述: 检测列表框元素重复
function chkDup( item, list )
{
for ( i=0; i<list.options.length; i++ ){
//alert( item + " - " + list.options[i].value );
if ( item == list.options[i].value ){
return true;
}
}
return false;
}

//描述: 选择列表框的全部成员
function selSel( list, item )
{
item.value = " ";
for ( i=0; i<list.options.length; i++ ){
list.options[i].selected=true;
item.value += list.options[i].value + " ";
}

}

function selSelSingle( list, value )
{
for ( i=0; i<list.options.length; i++ ){
if ( list.options[i].value == value ){
list.options[i].selected=true;
break;
}
}

}
//描述: 根据数组初始化列表框
function selList( item, arr )
{

var curIndex, insIndex, val, text;
var arrItem = new Array();

if ( item ){

item.length = 0;
curIndex = 0;

for ( i=0; i<arr.length; i++ ){

item.length ++;
insIndex = item.length - 1;

if ( arr[i] ){
arrItem = arr[i].split( ", " );
text = arrItem[1];
val = arrItem[0];
item.options[ insIndex ].text = text;
item.options[ insIndex ].value= val;
}
}

}
}

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:介绍一个判断plug-ins/ActiveX 是否存在的例子
· 下一篇:层不能跨框架(包括TEXTAREA)显示的解决办法
· ASP.NET之精通弹出窗口
· 改写即时消息的发送,包含同时给多人发送信息!
· C#中的域(field)和属性(property)
· ASP.NET页面间数据传递小结
· 使用ASP.NET 2.0中的GridView控件


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077