js实现下拉菜单提交表单后停留在选中option

<!DOCTYPE>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>成绩查询</title>
    <script src="./cjcx/js/jquery-1.10.1.min.js"></script>
</head>

<body>
    <form action="echo.php" method="get">
        <select name="se1" id="se1">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        </select>
        <a id="wen">123<a>
        <input type="submit" />
    </form>
    <script>
        $("#wen").click(function () {
            alert(123);
        })

        function GetRequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        //alert(window.location.search.substr(1));
        var se = GetRequest(se1)['se1'];
        var se = "'" + se + "'";
        $("#se1 option[value=" + se + "]").attr("selected", "true");
    </script>
</body>

</html>

猜你喜欢

转载自blog.csdn.net/qq_24729895/article/details/51839033
今日推荐