0

因此,我正在尝试创建一个简单的选择表单,就像您现在在大多数网站上看到的那样。当您单击其他选项时,我无法让它转到下一页。

<div class="pages" style="text-align:center; padding-top:10px; ">Navigation:
    <select style="width:300px;">
        <option value="/files/articles/1.html" selected="selected">1.Introduction</option>
        <option value="/files/images/6.html">2. images</option>
        <option value="/files/video/7.html">3. Video</option>
        <option value="/files/news/8.html">4. News</option>
    </select>
</div>

http://jsfiddle.net/yJM5c/5/

4

4 回答 4

0
<script type="text/javascript">
    $(document).ready(function() {
        $(".pages select").change(function() {
            window.location = $(".pages select option:selected").val();
        });
    });
</script>
于 2013-09-21T07:57:44.220 回答
0

You want to listen to the onchange event, so that when the value in the select tag changes you grab that value and then navigate to that url like so:

Javascript

function onChangeNavigate(d) {
  window.top.location = d.value;
}

html

<div class="pages" style="text-align:center; padding-top:10px; ">Navigation:
    <select onchange="onChangeNavigate(this)" style="width:300px;">
          <option value="/files/articles/1.html" selected="selected">1. Introduction</option>
           <option value="/files/images/6.html">2. images</option>
           <option value="/files/video/7.html">3. Video</option>
           <option value="/files/news/8.html">4. News</option>
    </select>
</div>

MDN Onchange

于 2013-09-21T07:57:46.080 回答
0
   <div class="pages" style="text-align:center; padding-top:10px; ">Navigation:
                    <select style="width:300px;" onchange="nextpage(this)">
                        <option value="/files/articles/1.html" selected="selected">1. Introduction</option>
                        <option value="/files/images/6.html">2. images</option>
                        <option value="/files/video/7.html">3. Video</option>
                        <option value="/files/news/8.html">4. News</option>
                    </select>
                    </div>


    <script type="text/javascript">
    function nextpage(select){
        window.location = select.value;
    }
    </script>
于 2013-09-21T07:59:42.230 回答
0

改变这个:<select style="width:300px;"> 到这个<select style="width:300px;" onchange="document.location = this.value">

于 2013-09-21T08:02:45.017 回答