87,910
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>邮编查询</title>
</head>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
$(document).ready(function(){
$("#s1").change(function(){
var $text=jQuery("#s1 option:selected").val();
alert($text);
});
});
</script>
<body>
#set($jquery="$.")
<form action="/Test/hello" method="post">
<div align="center">
<h1>邮编查询</h1>
<table align="center">
请选择要查询的城市或地区:
<select id ="s1" name="select1">
<option selected>请选择省/直辖市</option>
#foreach ($element in ${list})
<option>$element</option>
#end
</select>
<select id ="s2" name="select2">
<option selected>请选择市</option>
<option>$text</option>
</select>
<select id ="s3" name="select3">
<option selected>请选择县</option>
</select>
<input type="submit" value="提交" name="submit" />
<br></br>
</table>
</div>
</form>
</body>
</html>
<script>
$(document).ready(function(){
$("#s1").change(function(){
$text=jQuery("#s1 option:selected").val(); //这里的 var 去掉
alert($text);
});
});
</script>
再参考下这里
http://www.cnblogs.com/ajun/archive/2012/05/13/2498183.
http://www.w3school.com.cn/tiy/t.asp?f=jquery_ajax_post