我有一个下拉列表onchange
事件。当用户改变下拉框时,Ajax调用并显示结果。这一切工作正常。下降与onchange事件
我在模板中有以下列表。
Apple
Pineapple
当用户更改下拉值时。然后结果合并
Orange
Graps
Apple
Pineapple
但输出应该是这样的。
Orange
Graps
我不知道该怎么做。请帮帮我。这是我的base。这是我的movie_list模板。这是我的movie_sort模板。这是我的view。谢谢:-)
更新:这里是ajax代码。
function sortMovie(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/moviesort/?q="+str,true);
xmlhttp.send();
}
下拉
<select name="category" onchange="sortMovie(this.value)">
<option value="">Choose</option>
{% for category in categories %}
<option value="{{ category.id}}">{{category.name}}</option>
{% endfor %}
</select>
试试这个回答:http://stackoverflow.com/questions/5442104/what-is-the-best-jquery-multiselect-picker-for-hierarchical-data – PhoebeB