Skip to content

Instantly share code, notes, and snippets.

@salieridk
Created April 17, 2012 10:59
Show Gist options
  • Save salieridk/2405304 to your computer and use it in GitHub Desktop.
Save salieridk/2405304 to your computer and use it in GitHub Desktop.
Javascript: Add data from JSON to <select>
var options_departments = '<option>The first option goes here<\/option>';
$.each(banks, function(i,x){
options_departments += '<option value="' + x.name + '">' + x.name + '<\/option>';
});
$("select#divName", this).html(options_departments);
$("select#divName", this).change(function(){
var index = $(this).get(0).selectedIndex;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment