// author: dow " /> 秋霞毛片,中文字幕日韩经典,九九热在线视频免费观看

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

用prototype實現(xiàn)的簡單小巧的多級聯(lián)動菜單

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

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

主站蜘蛛池模板: 杰奎琳·卡瓦霍| 风间由美风间ゆみav| 极地特快电影英文版| 浙江卫视回放观看入口| 怒放的生命简谱| 爱的掌门人| 陈建斌电影| 蝴蝶视频在线观看| 孙兴电影| 真的爱你最标准谐音歌词| 男生女生向前冲第六季2014| 王菲电影| 日本动漫天使之剑| 生死瞬间演员表| 喜羊羊开心闯龙年| 王风| 松岛菜菜子| cctv神断狄仁杰第四部免费观看 | 致命录像带| 地铁女孩| 噜啊噜在线视频| 抖音怎么开店卖东西| 神州第一刀电影免费观看| 狼来了电影免费观看| 满天星的电影都有哪些| 卫途轮胎| 天下第一楼结局| right here waiting中文版| 密桃成孰时| 美丽的坏女人中文字幕| 张俪作品| 燃冬海报| 电影痴汉电车| 《流感》高清在线观看| 机械师3| 又见阿郎电视剧免费观看| 山东教育电视台直播| 封神第一部| 松滋100网| 寻梦环游记英文| 性感美女写真视频|