开发者

How to change options in a select list, based on the selected option of a previous select list?

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]));
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜