Skip to content

Instantly share code, notes, and snippets.

@huoxito
Created September 25, 2011 01:34
Show Gist options
  • Save huoxito/1240096 to your computer and use it in GitHub Desktop.
Save huoxito/1240096 to your computer and use it in GitHub Desktop.
jquery examples
$(document).ready(function(){
$('#marca').change(function(){
var marca = $('#marca option:selected').val();
$.getJSON('static/javascripts/models/models', function(data){
var items = '';
$.each(data, function(idx,value) {
if(marca == value['make']){
items += '<option value="' + value['model'] + '">' + value['model'] + '</option>';
}
});
$('#model').html(items);
});
});
$('#model').change(function(){
var model = $('#model option:selected').val();
$.getJSON('static/javascripts/models/versions', function(data){
var items = '';
$.each(data, function(idx,value) {
if(model == value['model']){
items += '<option value="' + value['version'] + '">' + value['version'] + '</option>';
}
});
$('#version').html(items);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment