【问题标题】:Category drop-down with auto submit自动提交的类别下拉列表
【发布时间】:2013-11-11 19:32:47
【问题描述】:

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

<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 中断了。有没有办法解决?谢谢!

【问题讨论】:

  • 这个问题似乎是题外话,因为它是关于纯 javascript,而不是关于 EECMS。

标签: categories javascript


【解决方案1】:

如果你想使用 jQuery:

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

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

【讨论】:

    【解决方案2】:
        <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多