Skip to content

Instantly share code, notes, and snippets.

@piersadrian
Last active December 13, 2015 17:19
Show Gist options
  • Save piersadrian/4947108 to your computer and use it in GitHub Desktop.
Save piersadrian/4947108 to your computer and use it in GitHub Desktop.
array = response['equipmentItems'];
parentElement = $('select')[0];
for (var i = 0; i < array.count; i++) {
currentObj = array[i];
newElement = document.createElement('option');
newElement.value = currentObj.someAttribute;
newElement.innerText = "Some Label";
for (prop in currentObj) {
if ( currentObj.hasOwnProperty(obj) ) {
newElement.setAttribute("data-" + prop, currentObj[prop]);
}
}
parentElement.appendChild(newElement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment