通过jQuery打造支持汉字,拼音,英文快速定位查询的超级select插件

2020-05-18 09:02:10易采站长站整理

$(‘#selectcontent’).remove();
});
}
//创建 select 下拉 div 容器
function creatediv() {
var divheight;
objid = obj.attr(‘id’);
objid = objid.replace(“selectinput”, “”);
$(‘.selectimg’).attr(“src”, “img/multiselect.gif”);
// objid = $(this).attr(‘id’);
$(‘#’ + imgselect + objid).attr(“src”, “img/multiselect-hover.gif”);
$(‘#’ + selectinputname + objid).focus();
selectwidth = obj.width();
//浏览器判断
if ($.browser.mozilla) {
selectwidth = selectwidth + 16;
} else {
selectwidth = selectwidth + 20;
}
//divheight=$(‘#’+objid).l;
//列表div
var myhtml1 = “<div id=’selectcontent’ style=’height: 118px; position:absolute; border: 1px solid #CCC; background:white; font-size:12;overflow-x:hidden;overflow-y:auto;margin: -1.5pt 0px 0pt 0px;display: none’></div>”;
$(‘#selectcontent’).remove();
obj.append(myhtml1);
$(“#selectcontent”).css({
‘font-size’: mfont,
‘width’: selectwidth,
});
$(‘#selectcontent’).show();
//加载option
createoption(0);
if (ij <= 8) {
divheight = ij * 15;
} else {
divheight = 118;
}
$(“#selectcontent”).css({
‘height’: divheight,
});
}
function arraycheck(objs, mystr) {
for (var i = 0; i < objs.length; i++) {
if (objs[i] == mystr) {
return false;
}
}
return true;
}
//创建 select option
function createoption(maction) {
objid = obj.attr(‘id’);
objid = objid.replace(“selectinput”, “”);
//加载select option 数据
$(‘#’ + objid).find(‘option’).each(function() {
fzrxm1 = fzrxm1 + $(this).val() + “|”;
fzrxm = fzrxm + $(this).text() + “|”;
});
var mystr = ”,
selectgoto = $(‘#’ + selectinputname + objid).val(),
selectstyle = ”,
seachstr = ”;
//alert(fzrxm1.length);
var myarray = new Array();  //创建一个数组
var arr = new Array();  //创建一个数组
fzrxm = fzrxm + ‘ ‘;
arr = fzrxm.split(‘|’);
seachstr = $(‘#selectinputname’ + objid).val();
//alert(seachstr);
//seachstr = objvalstr;
//$(‘#msg1’).html(seachstr + ‘aaaaaaaaaaaaaa’);
if ((seachstr != ”) && (seachstr != ‘undefined’)) {
if (maction == 1) {
var rval = GetAllLikeString(seachstr, arr);
}
if (maction == 0) {
var rval = arr;
}
} else {
var rval = arr;
}
mystr = “<div id=’selectdivtree’ style=’width:96.9%;border:0px solid #CCC;margin: 2pt 0px 0pt 2px;color:#000000′>”;
ij = 0;
recno = rval.length;