javascript - searching option from keyboard when different character encoding -


i have select tag has options in georgian:

<select>     <option value="1"> პირველი </option>     <option value="2"> მეორე </option>     <option value="3"> მესამე </option> </select> 

when expand select tag , press "მ" on keyboard, want search option begins on "მ". working fine default when characters written in english. have no idea how fix it, can suggest anything?

i don't have georgian characters on keyboard, @ least know russian:

html:

<select id="select">     <option value="0">Ноль</option>     <option value="1">Один</option>     <option value="2">Два</option>     <option value="3">Три</option>     <option value="4">Четыре</option>     <option value="5">Пять</option>     <option value="6">Шесть</option>     <option value="7">Семь</option>     <option value="8">Восемь</option>     <option value="9">Девять</option> </select> 

js:

document.getelementbyid('select').addeventlistener('keypress', function (event) {     var length = this.options.length;     var char = string.fromcharcode(event.which);     var keys = {         a: 'ф',         b: 'и',         c: 'с',         d: 'в',         e: 'у',         f: 'а',         g: 'п',         h: 'р',         i: 'ш',         j: 'о',         k: 'л',         l: 'д',         m: 'ь',         n: 'т',         o: 'щ',         p: 'з',         q: 'й',         r: 'к',         s: 'ы',         t: 'е',         u: 'г',         v: 'м',         w: 'ц',         x: 'ч',         y: 'н',         z: 'я',         '[': 'х',         ']': 'ъ',         ';': 'ж',         '\'': 'э',         ',': 'б',         '.': 'ю',         '/': '.',     };     var key = keys[char];     (var = 0; < length; i++) {         if (this.options[i].innerhtml.charat(0).tolowercase() === key) {             this.selectedindex = i;             break;         }     } }); 

and working example: http://jsfiddle.net/wdsqv/1/ (tested in firefox 20)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -