日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

列表框操作函数集合

發布時間:2023/11/27 生活经验 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 列表框操作函数集合 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 /* ?列表框互相操作函數集? */
??2
??3 // 描述:?添加不重復列表框元素
??4 function ?selAdd(?srcList,?dstList?)
??5 {
??6 ???? var ?selectedIndex? = ? new ?Array();
??7 ???? var ?count? = ? 0 ;
??8
??9 ???? for ?(?i = 0 ;?i < srcList.options.length;?i ++ ?){
?10
?11 ???????? if ?(?srcList.options[i].selected?){
?12 ????????????
?13 ????????????selectedIndex[count]? = ?i;
?14 ????????????count? ++ ;
?15
?16 ????????}
?17 ????}????????????????????
?18
?19 ???? for ?(?j = 0 ;?j < selectedIndex.length;?j ++ ?){
?20 ????????
?21 ????????k? = ?selectedIndex[j];
?22
?23 ???????? if ?(?chkDup(?srcList.options[k].value,?dstList?) == false ?){
?24 ???????? & ,?nbsp;???dstList.options.length ++ ;
?25 ???????????? var ?len? = ?dstList.options.length - 1 ;
?26 ????????????dstList.options[len].value? = ?srcList.options[k].value;
?27 ????????????dstList.options[len].text? = ?srcList.options[k].text;
?28 ????????}
?29
?30 ????}
?31
?32 }
?33
?34 // 描述:?刪除列表框元素
?35 function ?selDel(?list?)
?36 {
?37 ???? var ?len? = ?list.options.length;
?38 ???? var ?idx? = ? 0 ;
?39
?40 ???? while ?(?idx < ?len?){
?41
?42 ???????? if ?(?list.options[idx].selected?){
?43 ????????????list.options.remove(idx);
?44 ????????????len? = ?list.options.length;
?45 ????????}
?46 ???????? else {
?47 ????????????idx? ++ ;
?48 ????????}
?49 ????}
?50 }
?51
?52 // 描述:?檢測列表框元素重復
?53 function ?chkDup(?item,?list?)
?54 {
?55 ???? for ?(?i = 0 ;?i < list.options.length;?i ++ ?){
?56 ???????? // alert(?item?+?"?-?"?+?list.options[i].value?);
?57 ???????? if ?(?item? == ?list.options[i].value?){
?58 ???????????? return ? true ;
?59 ????????}
?60 ????}????????????????????
?61 ???? return ? false ;
?62 }
?63
?64 // 描述:?選擇列表框的全部成員
?65 function ?selSel(?list,?item?)
?66 {
?67 ????item.value? = ? " ? " ;
?68 ???? for ?(?i = 0 ;?i < list.options.length;?i ++ ?){
?69 ????????list.options[i].selected = true ;
?70 ????????item.value? += ?list.options[i].value? + ? " ? " ;
?71 ????}
?72
?73 }
?74
?75 function ?selSelSingle(?list,?value?)
?76 {
?77 ???? for ?(?i = 0 ;?i < list.options.length;?i ++ ?){
?78 ???????? if ?(?list.options[i].value? == ?value?){
?79 ????????????list.options[i].selected = true ;
?80 ???????????? break ;
?81 ????????}
?82 ????}
?83
?84 }
?85 // 描述:?根據數組初始化列表框
?86 function ?selList(?item,?arr?)
?87 {
?88
?89 ???? var ?curIndex,?insIndex,?val,?text;
?90 ???? var ?arrItem? = ? new ?Array();
?91
?92 ???? if ?(?item?){
?93
?94 ????????item.length? = ? 0 ;
?95 ????????curIndex? = ? 0 ;
?96
?97 ???????? for ?(?i = 0 ;?i < arr.length;?i ++ ?){
?98
?99 ????????????item.length? ++ ;
100 ????????????insIndex? = ?item.length? - ? 1 ;
101 ????????????
102 ???????????? if ?(?arr[i]?){
103 ????????????????arrItem? = ?arr[i].split(? " ,? " ?);
104 ????????????????text? = ?arrItem[ 1 ];
105 ????????????????val?? = ?arrItem[ 0 ];
106 ????????????????item.options[?insIndex?].text? = ?text;????
107 ????????????????item.options[?insIndex?].value = ?val;
108 ????????????}
109 ????????}
110
111 ????}
112 }?

總結

以上是生活随笔為你收集整理的列表框操作函数集合的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。