There are 2 inputs, in one the name is entered, in the other, the transliteration entered on the fly should be displayed.

  • 2
    Cool And the question is where? - Chad
  • There is no question - Saturn
  • obviously, implementation is required. - knes

2 answers 2


The plugin allows you to synchronize two fields on the form, with one field being the source of the data (for example, the title of the article), and the second (slug) receiving the translated text.

  • Exactly what is needed. Thank! - Saturn
var translit_array = []; //... //... translit_array[2] = array('в','v'); translit_array[3] = array('г','g'); translit_array[4] = array('д','d'); //... translit_array[31] = array('ю','yu'); translit_array[32] = array('я','ya'); //Можно использовать ассоциативный массив и, но меня уже разок щелкнули по носу за, вот, теперь извращаюсь for(var i=0;i<translit_array.length; i++){ var rep = new RegExp(translit_array[i][0]) $('textarea#mytextarea').val($('textarea#mytextarea').val().replace(rep,translit_array[i][1])); } 
  • translit_array[4] = ['д','d']; not? > I was already clicked just once on the nose for ... in can negatively affect the performance only if the property can be far away in the prototype chain, but if the object is clean and has only its own properties, then there is nothing to worry about no. in short, they "clicked" you for nothing =) but using such a selector 'textarea#mytextarea' is really not good, just id and everything else in the cycle changes the value of the text ... even suffered a micro optimization - Specter
  • one
    @Spectre is not a micro-optimization. If, for example, massive (but good) JavaScript code is written including such "errors", then, with a high degree of probability, not a single JS engine will be able to optimize it (even if it considers it necessary to do it). It’s also bad to do: arr [ 0] = ...; arr [1] = ...; arr [2] = ...; better this way: [ ..., ..., ... ]; It is better both aesthetically and, in some cases, from tz. Performance - Zowie
  • By the way, sometimes I met this way of working with arrays: // do something with array in loop arr [arr.length] = value; What caused this approach? - Specter
  • @Spectre - ignorance of the existence of the push method But this code is absolutely accurate! == calling push, this kind of record can sometimes very hard slow down your logic (I’ll enter a lot ). Why and how do I know this - ask for it is better, just take a word :) - Zowie
  • the creators of the underscore sometimes surprise me - Specter