国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

javascript實現(xiàn)通過拼音首字母快速選擇下拉列表

2024-05-06 14:17:57
字體:
供稿:網(wǎng)友
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>下拉列表快速選擇</title>


<script type="text/javascript" language="JavaScript">
// 獲取拼音首字母
function getPinYin(c) {
    execScript("tmp=asc(/""+c+"/")", "vbscript");
    tmp = 65536 + tmp;
    if(tmp>=45217 && tmp<=45252) return "A";
    if(tmp>=45253 && tmp<=45760) return "B";
    if(tmp>=45761 && tmp<=46317) return "C";
    if(tmp>=46318 && tmp<=46825) return "D";
    if(tmp>=46826 && tmp<=47009) return "E";
    if(tmp>=47010 && tmp<=47296) return "F";
    if((tmp>=47297 && tmp<=47613) || (tmp == 63193)) return "G";
    if(tmp>=47614 && tmp<=48118) return "H";
    if(tmp>=48119 && tmp<=49061) return "J";
    if(tmp>=49062 && tmp<=49323) return "K";
    if(tmp>=49324 && tmp<=49895) return "L";
    if(tmp>=49896 && tmp<=50370) return "M";
    if(tmp>=50371 && tmp<=50613) return "N";
    if(tmp>=50614 && tmp<=50621) return "O";
    if(tmp>=50622 && tmp<=50905) return "P";
    if(tmp>=50906 && tmp<=51386) return "Q";
    if(tmp>=51387 && tmp<=51445) return "R";
    if(tmp>=51446 && tmp<=52217) return "S";
    if(tmp>=52218 && tmp<=52697) return "T";
    if(tmp>=52698 && tmp<=52979) return "W";
    if(tmp>=52980 && tmp<=53688) return "X";
    if(tmp>=53689 && tmp<=54480) return "Y";
    if(tmp>=54481 && tmp<=62289) return "Z";
    return c.charAt(0);
}

// select helper
SelectHelper = new function() {
// 初始化
this.init = function() {
document.attachEvent("onkeypress", function() {
var elm = event.srcElement;
if (elm.tagName == "SELECT"
&& elm.className.indexOf("SelectHelper") == -1) {
elm.className += "SelectHelper";
elm.attachEvent("onkeypress", SelectHelper.getNextKeyItem);
elm.fireEvent("onkeypress", event);
}
});
}
// 獲取選項文本的首字符
function getItemKeyChar(option) {
return option.text.charAt(0).toUpperCase();
}
// 查找并選中匹配的選項
this.getNextKeyItem = function() {
var elm = event.srcElement;
var index = elm.selectedIndex + 1;
do {
if (index == elm.length) index = 0;
if (index == elm.selectedIndex) return false; // 未找到匹配的選項,則退出
} while (key2Char(event.keyCode) != getPinYin(getItemKeyChar(elm.options[index++])));
elm.selectedIndex = index - 1; // 選中匹配的選項
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 乌鲁木齐县| 新巴尔虎右旗| 龙海市| 萨嘎县| 桐柏县| 贵阳市| 陇南市| 启东市| 左云县| 莱西市| 东城区| 阜新市| 济源市| 长沙县| 麻江县| 达孜县| 周口市| 横峰县| 封开县| 邵阳县| 雷山县| 修武县| 鄂托克前旗| 若尔盖县| 洪泽县| 南木林县| 闽清县| 辽源市| 乌苏市| 寿宁县| 石阡县| 苍梧县| 昌邑市| 中牟县| 济宁市| 桃源县| 格尔木市| 寿光市| 哈巴河县| 凤庆县| 扎鲁特旗|