0

我正在使用这段代码将我的类别显示为下拉列表并使其自动提交:

<form>
<select onchange="this.form.submit()">
{exp:channel:categories channel="news"}
<option><a href="{path=news/list}">{category_name}</a> </option>
 {/exp:channel:categories}
</select>
</form> 

问题是 JavaScript 似乎在 URL 的末尾附加了一个问号,因此类别 URL 中断。有没有办法解决?谢谢!

4

2 回答 2

1

如果你想使用 jQuery:

$('.jump-menu').change(function() {
    location.href = $(this).val();
});

只需在您的选择中添加一个类.jump-menu,或相应地调整您的 jQuery 选择器。

于 2013-11-11T20:14:42.440 回答
0
    <select name="selcat" id="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
    {exp:channel:categories channel="news"}
    <option><a href="{path=news/list}">{category_name}</a> </option>
     {/exp:channel:categories}
    </select>
于 2013-11-11T20:12:10.703 回答