Skip to content

Instantly share code, notes, and snippets.

@gockxml
Created November 26, 2012 09:25
Show Gist options
  • Save gockxml/4147363 to your computer and use it in GitHub Desktop.
Save gockxml/4147363 to your computer and use it in GitHub Desktop.
bind_select
function bind_select(first, second, data){
var change = function(evt){
var first_elem = $(first)[0];
var second_elem = $(second);
second_elem.html("");
second_elem = second_elem[0]
values = data[first_elem.value]
for (var i=0, len = values.length; i < len; i++){
if (!(values[i] instanceof Array)){
values[i] = [values[i]]
}
console.log(values[i])
second_elem.options.add(new Option(values[i][0], values[i][1] || values[i][0]));
}
};
$(document).on('change', first, change);
//change()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment