// author: dow " /> 亚洲欧美中文v日韩v在线,午夜免费视频观看,国产精品午夜波多野结衣性色

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

用prototype實(shí)現(xiàn)的簡單小巧的多級(jí)聯(lián)動(dòng)菜單

使用prototype.js這個(gè)js庫,這個(gè)在網(wǎng)上一搜就能找到了,是一個(gè)開源的js函數(shù)庫。 
看到今天貼了幾個(gè)聯(lián)動(dòng)菜單的帖子
這個(gè)應(yīng)該大家都有各自比較好的代碼了
我也順手貼一個(gè)我們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]);   
    }   
  }   
}  
簡單說一下幾個(gè)參數(shù)吧: 
source 第一級(jí)菜單
target 聯(lián)動(dòng)菜單
ignore 當(dāng)有時(shí)候3級(jí)聯(lián)動(dòng)時(shí),例如 國家 省 市 例如上海沒有省的,可以忽略第3級(jí)菜單
url action url
options action參數(shù)
excute 是否聯(lián)動(dòng)
拿比較常見的例子來看 國家 省 市 3級(jí)聯(lián)動(dòng)來作為例子
代碼
<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技術(shù)用prototype實(shí)現(xiàn)的簡單小巧的多級(jí)聯(lián)動(dòng)菜單,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产精品香蕉在线一区 | 玖玖玖视频在线观看视频6 玖玖免费 | 天堂色在线 | 特级xxxxx欧美 | 狠狠色伊人亚洲综合第8页 狠狠色伊人亚洲综合网站l | 小泽玛利亚一区二区三区免费 | 日本www色视频成人免费 | 欧美色精品 | 久久精品a| 成人综合激情网 | 成人免费精品视频 | 欧美一卡2卡三卡四卡五卡 欧美一欧美一区二三区性 欧美一区a | 亚洲综合偷自成人网第页色 | 一本色道久久综合亚洲精品加 | 四虎精品视频在线永久免费观看 | 精品国产一区二区三区不卡在线 | 久久亚洲精品国产精品婷婷 | 日本一区午夜爱爱 | 色婷婷六月丁香在线观看 | 亚洲网站在线播放 | 久久国产精品国产精品 | 久久久久久久久久久大尺度免费视频 | 最新国产区 | 久久国产亚洲精品麻豆 | 亚洲图片欧美激情 | 欧美一卡2卡三卡四卡五卡 欧美一欧美一区二三区性 欧美一区a | 91香蕉嫩草 | 中文字幕在线视频观看 | 国产1级毛片 | 亚洲免费小视频 | 激情婷婷六月 | 亚洲伊人久久大香线蕉苏妲己 | 性欧美video另类3d | 性欧美xxxx视频在线观看 | 九九久久亚洲综合久久久 | 四虎最新紧急入口4hu | www一区二区 | 黄色免费在线视频 | 色久悠悠色久在线观看 | 日本午夜vr影院新入口 | 伊人狠狠色j香婷婷综合 |