inthis.addClass("btn_up");
e.data.input.focus();
});
//选中下拉框中一个指定索引的值(如果是multiple模式,且这个值原来已经被选定,则运行此函数后将会取消该选定)
this.selectValue=function(index){
if(index>0&&index<this.$data.length){
var p=this.$list.children("a:eq("+index+")");
if(this.$lastSelect)this.$lastSelect.removeClass("active");
this.$lastSelect=p;
p.click();
}
};
//绑定下拉列表单元被点击时的事件
this.$list.bind("click",{inthis:this},function(e){
if ( e && e.preventDefault )e.preventDefault();//阻止默认浏览器动作(W3C)
elsewindow.event.returnValue = false;//IE中阻止函数器默认动作的方式
if(!e) e=window.event;
var clicked=$(e.target);
var inthis=e.data.inthis;
if(clicked.attr("tagName")=="A")clicked=clicked.children("p");
else if(clicked.attr("tagName")=="UL"){
this.style.display="none";
return;
}
if(inthis.$haveIcon){
inthis.$input.parent(".text").css({
background:clicked.css("background"),
"background-image":"url(../images/combo_icon.gif)",
"background-position":clicked.css("background-position"),
"background-repeat":clicked.css("background-repeat")
});
}
if(inthis.$type!="multiple"){
if(inthis.$lastSelect)inthis.$lastSelect.removeClass("active");
inthis.$lastSelect=clicked.parent("a").addClass("active");
this.style.display="none";
inthis.$select.val(clicked.attr("value"));
inthis.$input.val(clicked.text());
}
else{
clicked.parent("a").toggleClass("active");
var optionList=inthis.$select.get(0).options;
for(var i=0;i<optionList.length;++i){
if(optionList[i].value==clicked.attr("value")){
optionList[i].selected=!optionList[i].selected;
break;
}
}
inthis.$input.val(clicked.text()+" , ……");
}
inthis.$select.change();
//alert(inthis.$select.val());
return false;
});
//绑定当用户用鼠标上/下滑过选择列表内容时的事件
this.$list.bind("mouseover",{list:this.$list},function(e){
if(!e) e=window.event;
var clicked=$(e.target);
if(clicked.attr("tagName")=="P")clicked=clicked.parent("a");
else if(clicked.attr("tagName")=="UL"){
return;
}
clicked.focus();
clicked.addClass("focus");
});
this.$list.bind("mouseout",{list:this.$list},function(e){
if(!e) e=window.event;
var clicked=$(e.target);
if(clicked.attr("tagName")=="P")clicked=clicked.parent("a");
else if(clicked.attr("tagName")=="UL")return;
clicked.removeClass("focus");
});
//绑定当用户用上/下方向键选择列表内容时的事件
this.$list.bind("keydown",{inthis:this},function(e){
if(!e) e=window.event;
var inthis=e.data.inthis;
if(e.keyCode==13){//回车
if ( e && e.preventDefault )e.preventDefault();//阻止默认浏览器动作(W3C)
elsewindow.event.returnValue = false;//IE中阻止函数器默认动作的方式










