H开发者_JAVA技巧ow to change options in a select list, based on the selected option of a previous select list?
Try this tread.
you cant do dynamic like this via simple html. You should use javascript for example. In google there are a lot of solutions, this is one of them: http://programmersforum.ru/showpost.php?p=227550&postcount=3
The easiest way to do this is to use jQuery.
For example:
var categoryItems = {
'Car': [ 'Acura', 'Honda', 'Toyota' ],
'Computer: [ 'Dell', 'HP', 'Lenovo' ],
'Search engine': [ 'Google', 'Bing', 'Yahoo' ]
};
$('#category').change(function() {
var itemsDropdown = $('#items').empty();
var items = categoryItems[$(this).val()];
for(var i = 0; < items.length; i++)
itemsDropdown.append($('<option />').text(items[i]));
});
精彩评论