您的位置:首页 > Web前端 > JavaScript

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

2016-07-06 15:05 519 查看
<!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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: