Created
September 25, 2011 01:34
-
-
Save huoxito/1240096 to your computer and use it in GitHub Desktop.
jquery examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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