Skip to content

Instantly share code, notes, and snippets.

@hattmarris
Last active August 29, 2015 14:27
Show Gist options
  • Save hattmarris/d092c0fd1d39fd08dca0 to your computer and use it in GitHub Desktop.
Save hattmarris/d092c0fd1d39fd08dca0 to your computer and use it in GitHub Desktop.
// define example vars
var dataList = document.getElementById('suggestions'),
letters = 'abcdefghijklmnopqrstuvwxyz',
choices = letters.split(''),
doubled = [];
// doubled letters
for(var i in choices) {
var s = choices[i] + choices[i];
doubled.push(s);
}
choices = choices.concat(doubled);
// populate datalist HTML5 method
// loop and add permutations of letters as options
for(var i=0; i<choices.length; i++) {
var option = document.createElement('option');
option.value = choices[i];
dataList.appendChild(option);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment