<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨心蕓蕓 @ JPeanut(舊版)

    搬遷至 http://www.17m.net.cn/

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      43 Posts :: 0 Stories :: 54 Comments :: 0 Trackbacks

    <陳市明摘自:http://www.tkk7.com/JPeanut>

    在公司需求預測模塊開發了無限級下拉菜單js版本
    下載


    ??1 使用注意一下幾點: < br >
    ??2 < OL >
    ??3 ???? < LI > selected?屬性?:?index(索引,必填)??defalut(默認值,可選)
    ??4 ???? < LI > array(a,b,c)?:?a(上級下拉的值域,b當前級下拉的值域,c當前級下拉值域對應的顯示的字符串)
    ??5 ???? < LI > 調用方法:
    ??6 ???????? < pre >
    ??7 ????????var?loarbar?=?new?bsteel_associate_list(
    ??8 ????????????new?Array(??????????????????????????????????????? < ---- 下拉關聯屬性
    ??9 ????????????????new?Array("ff.a",a_array),???????????????????<----new?Array("表單屬性名",數組)
    ?10 ????????????????new?Array("ff.b",b_array),
    ?11 ????????????????new?Array("ff.c",c_array)
    ?12 ????????????),
    ?13 ????????????3,????????????????????????????????????????????????<----數量
    ?14 ????????????'請選擇'??????????????????????????????????????????????<----第一條選擇的option的
    ?15 ????????);
    ?16 ????????</pre >
    ?17 ???? < LI >
    ?18 ???? < LI >
    ?19 </ OL >
    ?20 < form? method =post? action ="" ?name ="ff" >
    ?21 ???? < select? name ="a" ?index ="0" ? ></ select >
    ?22 ???? < select? name ="b" ?index ="0" ></ select >
    ?23 ???? < select? name ="c" ?index ="0" ></ select >
    ?24 ???? < hr >
    ?25 ???? < select? name ="a" ?index ="1" ?defalut ="1" ></ select >
    ?26 ???? < select? name ="b" ?index ="1" ?defalut ="12" ></ select >
    ?27 ???? < select? name ="c" ?index ="1" ?defalut ="121" ></ select >
    ?28 ???? < hr >
    ?29 ???? < select? name ="a" ?index ="2" ? ></ select >
    ?30 ???? < select? name ="b" ?index ="2" ></ select >
    ?31 ???? < select? name ="c" ?index ="2" ></ select >
    ?32 ???? < hr >
    ?33 </ form >
    ?34 < script? language ="javascript" >
    ?35 <!--
    ?36
    ?37
    ?38 ????a_array? = ? new ?Array( new ?Array( "" , " 1 " , " [1] " ), new ?Array( "" , " 2 " , " [2] " ));
    ?39 ????b_array? = ? new ?Array( new ?Array( " 1 " , " 11 " , " [11] " ), new ?Array( " 1 " , " 12 " , " [12] " ), new ?Array( " 2 " , " 21 " , " [21] " ), new ?Array( " 2 " , " 22 " , " [22] " ));
    ?40 ????c_array? = ? new ?Array( new ?Array( " 11 " , " 111 " , " [111] " ), new ?Array( " 11 " , " 112 " , " [112] " ), new ?Array( " 12 " , " 121 " , " [121] " ), new ?Array( " 12 " , " 122 " , " [122] " ));
    ?41
    ?42
    ?43
    ?44 ????? var ?loarbar? = ? new ?bsteel_associate_list(
    ?45 ???????? new ?Array(
    ?46 ???????????? new ?Array( " ff.a " ,a_array),
    ?47 ???????????? new ?Array( " ff.b " ,b_array),
    ?48 ???????????? new ?Array( " ff.c " ,c_array)
    ?49 ????????),
    ?50 ???????? 3 ,
    ?51 ????????'請選擇'
    ?52 ????);
    ?53 ????loarbar.init();
    ?54 ?
    ?55
    ?56 ????
    ?57 ???? /* *
    ?58 ?????*??作者:?陳市明
    ?59 ?????*??作用:無限級關聯下拉菜單
    ?60 ?????*??用法:
    ?61
    ?62 ?
    ?63 ????? */

    ?64 ???? function ?bsteel_associate_list(lists,count,firstStr) {
    ?65 ???????? this .count? = ?count;
    ?66 ???????? this .init? = ?onload_associate_list;
    ?67 ???????? this .onchange_associate_list? = ?onchange_associate_list;
    ?68 ???????? this .remove_list_option? = ?remove_list_option;
    ?69 ???????? this .update_input_name? = ?update_input_name;
    ?70 ???????? this .static_associate_list? = ?lists;
    ?71 ???????? this .count? = ?count;
    ?72 ???????? this .firstStr? = ?firstStr;
    ?73
    ?74 ????}

    ?75
    ?76 ???? function ?update_input_name(obj) {
    ?77 ???????? if (obj.index != " undefined " ) {
    ?78 ???????????? return ?obj.name + " [ " + obj.index + " ] " ;
    ?79 ????????}
    else {
    ?80 ???????????? return ?obj.name;
    ?81 ????????}

    ?82 ????}

    ?83
    ?84
    ?85 ???? function ?onload_associate_list() {
    ?86 ???????? var ?i,j;
    ?87 ???????? var ?x,y;
    ?88
    ?89 ???????? for (x = 0 ,y = this .count;x < y;x ++ ) {
    ?90 ???????????? for (i = 0 ,j = this .static_associate_list.length;i < j;i ++ ) {????????????????
    ?91 ????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).options.add( new ?Option( this .firstStr, "" ));
    ?92 ????????????????
    ?93 ????????????}

    ?94
    ?95 ????????}
    ????????
    ?96
    ?97 ???????? // 初始化所有的表單?的?全局變量
    ?98 ????????
    ?99 ???????? for (x = 0 ,y = this .count;x < y;x ++ ) {
    100 ???????????? for (i = 0 ,j = this .static_associate_list.length;i < j;i ++ ) {????
    101 ????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).setAttribute( " static_associate_list " , this .static_associate_list);
    102 ????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).setAttribute( " static_associate_count " , this .count);
    103 ????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).setAttribute( " firstStr " , this .firstStr);
    104 ????????????}

    105 ????????}

    106
    107
    108 ???????? // 初始化所有的表單?的?數據
    109 ???????? var ?a_array? = ? this .static_associate_list[ 0 ][ 1 ];
    110
    111 ???????? for (x = 0 ,y = this .count;x < y;x ++ ) {
    112 ???????????? for (i = 0 ,j = a_array.length;i < j;i ++ ) {
    113 ????????????????eval( this .static_associate_list[ 0 ][ 0 ] + update_list_index(x, this .count)).options.add( new ?Option(a_array[i][ 2 ],a_array[i][ 1 ]));
    114 ????????????}

    115 ????????}
    ????
    116
    117
    118 ???????? // 初始化所有的表單?添加?onchange?觸發動作
    119 ???????? for (x = 0 ,y = this .count;x < y;x ++ ) {
    120 ???????????? for (i = 0 ,j = this .static_associate_list.length - 1 ;i < j;i ++ ) {????????
    121 ????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).onchange? = ?onchange_associate_list;
    122 ????????????}

    123 ????????}
    ????
    124
    125 ???????? // 初始化所有的表單?的?默認值
    126 ????????
    127 ???????? for (x = 0 ,y = this .count;x < y;x ++ ) {
    128 ???????????? for (i = 0 ,j = this .static_associate_list.length - 1 ;i < j;i ++ ) {????
    129 ?????????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).value? = ?eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).defalut;
    130 ????????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).onchange();
    131 ???????????????????? // 在沒有默認值的情況下,選擇第一列:請選擇
    132 ???????????????????? if (eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).selectedIndex <= 0 ) {
    133 ????????????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).selectedIndex? = ? 0 ;
    134 ????????????????????}
    ????????????????
    135 ????????????????}
    ????????????
    136 ????????????}

    137
    138 ?????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).value? = ?eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).defalut;
    139 ???????????????? // 在沒有默認值的情況下,選擇第一列:請選擇
    140 ???????????????? if (eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).selectedIndex <= 0 ) {
    141 ????????????????????eval( this .static_associate_list[i][ 0 ] + update_list_index(x, this .count)).selectedIndex? = ? 0 ;
    142 ????????????}

    143 ????????}

    144
    145
    146
    147
    148 ????}
    149
    150 ???? function ?onchange_associate_list() {
    151 ????????remove_list_option( this );
    152 ???????? var ?nextObj;
    153 ???????? var ?array;
    154 ???????? var ?i,j;
    155 ???????? for (i = 0 ,j = this .static_associate_list.length;i < j;i ++ ) {????
    156 ???????????? if (( this .form.name + " . " + this .name) == this .static_associate_list[i][ 0 ]) {????????????????????
    157 ????????????????nextObj? = ?eval( this .static_associate_list[i + 1 ][ 0 ] + update_list_index( this .index, this .static_associate_count));
    158 ????????????????array? = ? this .static_associate_list[i + 1 ][ 1 ];
    159 ???????????????? break ;
    160 ????????????}

    161 ????????}

    162
    163 ???????? // nextObj.options.add(new?Option("請選擇",""));
    164 ???????? for (i = 0 ,j = array.length;i < j;i ++ ) {
    165 ???????????? if ( this .value == array[i][ 0 ]) {
    166 ????????????????nextObj.options.add( new ?Option(array[i][ 2 ],array[i][ 1 ]));
    167 ????????????}

    168 ????????}

    169 ????}

    170
    171 ???? function ?remove_list_option(currentObj) {????
    172 ???????? var ?remove_flag? = ? false ;
    173 ???????? var ?i,j;
    174 ???????? for (i = 0 ,j = currentObj.static_associate_list.length;i < j;i ++ ) {????????????
    175 ???????????? if (remove_flag) {
    176 ????????????????remove_list_all_option(eval(currentObj.static_associate_list[i][ 0 ] + update_list_index(currentObj.index,currentObj.static_associate_count)));
    177 ????????????????remove_flag? = ? true ;
    178 ????????????}

    179 ???????????? if ((currentObj.form.name + " . " + currentObj.name) == currentObj.static_associate_list[i][ 0 ]) {
    180 ????????????????remove_flag? = ? true ;
    181 ????????????}

    182 ????????}

    183 ????}

    184 ????
    185 ???? function ?remove_list_all_option(listObj) {????
    186 ???????? var ?i,j;
    187 ???????? for (i = 0 ,j = listObj.length;i < j;i ++ ) {
    188 ????????????listObj.options.remove( 0 );
    189 ????????}

    190 ????????listObj.options.add( new ?Option(listObj.firstStr, "" ));
    191 ????}

    192 ????
    193 ???? function ?update_list_index(index,count) {
    194 ???????? if (index == " undefined " ? || ?count == " undefined " ? || ?count + "" == " 1 " ) {
    195 ???????????? return ? "" ;
    196 ????????}
    else {
    197 ???????????? return ? " [ " + index + " ] " ;
    198 ????????}

    199 ????}

    200 ?
    201 // -->
    202
    </ script >





    ?

    posted on 2006-11-21 12:51 陳市明 閱讀(1425) 評論(0)  編輯  收藏 所屬分類: 軟件開發

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 麻豆国产精品入口免费观看| 亚洲日韩久久综合中文字幕| www国产亚洲精品久久久| 57pao一国产成视频永久免费| 免费精品久久久久久中文字幕| 亚洲精品二三区伊人久久| 久热综合在线亚洲精品| 亚洲日本中文字幕天堂网| 免费的涩涩视频在线播放| 97人妻无码一区二区精品免费| 免费无码又爽又刺激网站| ssswww日本免费网站片| 激情小说亚洲色图| 亚洲人成网亚洲欧洲无码| 亚洲国产成人在线视频 | 美女被免费视频网站a| 97se亚洲国产综合自在线| 久久久久久亚洲精品| 中文字幕精品无码亚洲字| 亚洲成av人片天堂网老年人| 日本成人免费在线| 午夜成人免费视频| 成人免费在线观看网站| 欧亚精品一区三区免费| 无码中文在线二区免费| 国产麻豆视频免费观看| 丁香花免费完整高清观看| 国色精品卡一卡2卡3卡4卡免费| 67pao强力打造国产免费| **aaaaa毛片免费| 美丽的姑娘免费观看在线播放| 一区二区三区在线免费看 | 亚洲精品国产专区91在线| 久久久亚洲裙底偷窥综合| 久久亚洲私人国产精品vA | 色www永久免费网站| 国产在线观看免费av站| 免费人成毛片动漫在线播放| 免费在线观看一级片| 91高清免费国产自产拍2021| 国内精品免费麻豆网站91麻豆|