| 网站首页 | 硬件维修 | 应用学院 | 网络组建 | 网站制作 | 菜鸟黑客 | 编程之道 | 数码大全 | 娱乐休闲 | 软件下载 | 在线视频 | 请您留言 | 技术论坛 | 
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
  • 完美解决一个事件激活多个函…

  • 完美解决一个事件激活多个函…

  • 用javascript绘图—JS2D…

  • 在客户端设置cooke和获取coo…

  • 一个解析URL及图片地址的JS函…

  • 用javascript绘图—JS2D…

  • HTML4标签的默认样式列表

  • 日期相加的函数addDate

  • 校验日期的函数

  • 通用表单验证函数

  • Q
    您现在的位置: 我是IT人 >> 网站制作 >> ASP >> 文章正文
    列表框操作函数集合         
    列表框操作函数集合
    作者:网络 文章来源:转载 点击数: 更新时间:2005-9-30
    [ 字体:缩小 正常 放大 | 双击自动滚屏 ]
    请选择合适的字体颜色:


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

    //描述: 添加不重复列表框元素
    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;
    }
    }

    [1] [2] 下一页  

    文章录入:小秦    责任编辑:小秦 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 关于我们 | 友情链接 | 版权申明 |