国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript列表框操作函數集合匯總

2019-11-20 21:34:08
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

<script language="javascript">

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

  //描述: 添加不重復列表框元素
  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 ){
       &, nbsp;   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;
            }
        }

    }
}

    </script>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏尼特左旗| 渝中区| 萝北县| 霍州市| 潮安县| 松滋市| 滦平县| 和田市| 桂东县| 新竹县| 洪湖市| 利辛县| 县级市| 金山区| 贵溪市| 庐江县| 扎鲁特旗| 贡嘎县| 克山县| 耒阳市| 云林县| 河东区| 墨脱县| 南宫市| 云浮市| 乌兰浩特市| 文登市| 闽侯县| 叙永县| 崇阳县| 绍兴县| 安远县| 阜南县| 东阳市| 和平县| 云和县| 府谷县| 沁水县| 平原县| 华宁县| 五峰|