// author: dow " /> 在线观看黄网站,亚洲视频久久,色之综合网

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

用prototype實現的簡單小巧的多級聯動菜單

使用prototype.js這個js庫,這個在網上一搜就能找到了,是一個開源的js函數庫。 
看到今天貼了幾個聯動菜單的帖子
這個應該大家都有各自比較好的代碼了
我也順手貼一個我們team里面用的比較小巧的代碼

// author: downpour   
var DoubleCombo = Class.create();   
DoubleCombo.prototype = {   
  initialize: function(source, target, ignore, url, options, excute) {   
    this.source = $(source);   
    this.target = $(target);   
    this.ignore = $A(ignore);   
    this.url = url;   
    this.options = $H(options);   
    this.source.onchange = this.doChange.bindAsEventListener(this);   
    if(excute) {   
        this.doChange();   
    }   
  },   
  doChange: function() {   
    if(this.source.value != '') {   
        // first clear the ignore ones   
        this.ignore.each(   
            function(value) {   
                $(value).options.length = 1;   
                $(value).options[0].selected = 'selected';   
            }   
        );   
        // create parameter for ajax   
        var query = $H({ id: this.source.value });   
        var parameters = {   
            method: 'post',    
            parameters: $H(this.options).merge(query).toQueryString(),    
            onComplete: this.getResponse.bindAsEventListener(this)   
        }   
        var locationRequest = new Ajax.Request( this.url, parameters );   
    }   
  },   
  getResponse: function(request) {   
    this.target.options.length = 1;   
    this.target.options[0].selected = 'selected';   
    var response = $A(request.responseText.trim().split(';'));   
    response.length--;   
    for(var i = 0; i < response.length; i++) {   
        var optionParam = response[i].split(',');   
        this.target.options[this.target.options.length] = new Option(optionParam[1], optionParam[0]);   
    }   
  }   
}  
簡單說一下幾個參數吧: 
source 第一級菜單
target 聯動菜單
ignore 當有時候3級聯動時,例如 國家 省 市 例如上海沒有省的,可以忽略第3級菜單
url action url
options action參數
excute 是否聯動
拿比較常見的例子來看 國家 省 市 3級聯動來作為例子
代碼
<html-el:select property="country" styleId="country" >  
    <html-el:options collection="countries" property="id" labelProperty="name" />  
</html-el:select>  
<html-el:select property="province" styleId="province">  
    <option value="">--Please Select--</option>  
         ................   
</html-el:select>  
<html-el:select property="city" styleId="city">  
    <option value="">--Please Select--</option>  
         ................   
</html-el:select>  
<script type="text/Javascript">  
    new DoubleCombo('country', 'province', null, '<c:url value="/xxxx.do?combo=true"></c:url>', {});   
<script type="text/Javascript">  
    new DoubleCombo('province', 'city', null, '<c:url value="/xxxx.do?combo=true"></c:url>', {}); 

JavaScript技術用prototype實現的簡單小巧的多級聯動菜單,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 一二三四在线播放免费视频中国 | 欧美日韩亚洲国产无线码 | 日韩经典欧美精品一区 | 亚洲图片欧美日韩 | 91亚洲免费视频 | 人人做人人爽人人爱秋霞影视 | 久久精品影院永久网址 | 78m.78摸免费视频 | 欧美日韩加勒比一区二区三区 | 久久99亚洲综合精品首页 | 国产美女免费国产 | 国产午夜人做人免费视频中文 | 真实子伦视频不卡 | 免费女人扒开下面无遮挡 | 国产日韩一区二区三区 | 91精品国产综合久久福利 | 日韩中文字幕免费版 | 欧美成人综合在线 | 亚洲丶国产丶欧美一区二区三区 | 免费污视频在线观看 | 综合 欧美 国产 视频二区 | 视频精品一区二区三区 | 性视频久久 | 色哟哟在线观看视频 | 四虎永久在线日韩精品观看 | 久久成 | 91日韩欧美 | 久久精品成人国产午夜 | 亚洲一区高清 | 韩国三级久久 | 在线亚洲欧洲国产综合444 | 亚洲第一页乱 | 成人国产精品视频 | 激情文学区 | 91国语对白 | 国产美女91 | 男女朋友做爽爽爽免费视频网 | 伊人免费在线 | 国产精品一区二区四区 | 日本精品久久久久中文字幕 1 | 狠狠综合久久综合鬼色 |