Yami Odymel Yami Odymel - 2 months ago 14
Javascript Question

Is it possible to generate all the emojis and append to the select dropdown?

Is there any possible ways to generate all the emojis and append them in to a single select dropdown by using JavaScript? Or I have to type each of them manually?

<select>
<option>

Answer

DEMO

you can define start and end values of different emoj lists ranges.then you can loop through each ranges and append emoj to option tag.

var mySelect = document.getElementById('mySelect')
var newOption;
var emojRange = [
  [128513, 128591] ,[9986,10160],[128640,128704]
];
//inside emojRange 2d array , define range arrays (start number,end number).
//1st array : Emoticons icons
//2nd range : Dingbats.
//3rd range : Transport and map symbols
for (var i = 0; i < emojRange.length; i++) {
  var range = emojRange[i];
  for (var x = range[0]; x < range[1]; x++) {

    newOption = document.createElement('option');
    newOption.value = x;
    newOption.innerHTML = "&#" + x + ";";
    mySelect.appendChild(newOption);
  }

}

i took hexadecimal ranges from this site http://apps.timwhitlock.info/emoji/tables/unicode.