快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

ope体育安全吗:用prototype实现的简单小巧的多级联动菜单



应用prototype.js这个js库,这个在网上一搜就能找到了,是一个开源的js函数库。

看到本日贴了几个联动菜单ope体育安全吗的帖子

这个应该大年夜家都有各自对照好的代码了

我也顺手ope体育安全吗贴一个我们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.bindAsEventListenerope体育安全吗(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

--Please Select--

................

--ope体育安全吗Please Select--

................

new DoubleCombo('country', 'province', ope体育安全吗null, '', {});

new DoubleCombo('province', 'city', null, '', {});

您可能还会对下面的文章感兴趣: