// author: dow " /> 免费黄色毛片,国产色视频网站,四虎最新入口

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

用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實現的簡單小巧的多級聯動菜單,轉載需保留來源!

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

主站蜘蛛池模板: 国产高清视频 | 国产精品欧美一区二区三区不卡 | 精品av| 97精品超碰一区二区三区 | 毛片一区 | 一区二区三区久久久 | 99久久免费精品国产免费高清 | 激情一区二区三区 | 天天躁天天操 | 色天堂视频 | 成人网av | 亚洲欧美日韩中文字幕一区二区三区 | 久久97精品 | 久久久中文 | 久久国产精品视频观看 | 午夜影院在线观看视频 | 亚洲自拍偷拍免费视频 | 成人在线精品 | 国产精品毛片一区二区在线看 | 成人伊人 | 久草成人网 | 亚洲444kkkk在线观看最新 | 日韩一区二区福利 | 呦呦在线视频 | 久久高清| av中文字幕在线播放 | 天堂网中文字幕在线观看 | 成人在线播放 | 91久久国产综合久久 | 国产精品国产 | 综合国产第二页 | 日韩一级电影免费观看 | 99只有精品| 日韩精品久久一区二区三区 | 色先锋影音 | 青青久久久 | 国产免费看 | 亚洲综合在线一区二区 | 人人干超碰| 国产欧美日韩一区二区三区 | 黄色毛片网站在线观看 |