<select onchange="filterschool()"></select>
<select onchange="filterdirection()"></select>
<a onclick="filterhot(1)">最新</a>
<a onclick="filterhot(2)">最熱</a>
<script type="text/javascript">
var schoolvalue = 0,
directionvalue = 0,
hotvalue = 0;
function filterschool(){
var obj = document.getElementById("filter-school");
var index = obj.selectedIndex;
schoolvalue = obj.options[index].value;
creaturl()
};
function filterdirection(){
var obj = document.getElementById("filter-direction");
var index = obj.selectedIndex;
directionvalue = obj.options[index].value;
creaturl()
}
function filterhot(hot){
hotvalue = hot;
creaturl()
}
function creaturl(){
url = schoolvalue+"/"+directionvalue+"/"+hotvalue;
console.log(url)
}
</script>
界面:
兩個select標籤,學校、方向。
兩個a標籤分別是最熱、最新。
選擇任意,生成一個url,實現篩選效果。