2010-10-12 144 views
1

我有一个表,它有一个类别的信息,比如一个产品。我已将它们列在下拉菜单中。现在,我需要做的是,在下一个下拉菜单中列出所选类别的子类别。我希望,JavaScript是必需的,但我不熟悉JavaScript。如何根据另一个下拉列表中的选项动态地填充下拉列表中的选项?

非常感谢您的帮助。

+0

尝试这些http://www.plus2net.com/php_tutorial/php_drop_down_list3.php http://www.plus2net.com/php_tutorial/php_drop_down_list.php – zod 2010-10-13 20:46:35

回答

3

您应该使用AJAX。

使用jQuery这是非常简单的:

$('#select1').change(function(){ 
$.ajax({ 
    //Send to php script category id. This script returns all subcategories 
    $.ajax({ 
     type: "POST", 
     url: location.href, 
     data: data, 
     success : function (data) 
     { 
     // Your return categories in data 
     // Append list options to select2 
     } 
}); 
}); 
+1

那第一个.ajax应该在那里? – khany 2014-05-20 15:21:28

相关问题