JQuery中的select事件是change事件,在js中使用的是onchange事件:
<script src="jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$('#mySelect').change(function(){
alert($(this).children('option:selected').val());
var p1=$(this).children('option:selected').val();//这就是selected的值
var p2=$('#param2').val();//获取本页面其他标签的值
window.location.href="xx.php?param1="+p1+"¶m2="+p2+"";//页面跳转并传参
})
})
</script>
<select id="mySelect">
<option value="1">one</option>
<option value="2" selected="selected">two</option>
<option value="3">three</option>
</select>
又如:
$(document).ready
(
function()
{
$("#showLoadingDiv").click(function(){$("#dataLoad").show();}); //为指定按钮添加数据加载动态显示:即将DIV显示出来
$("#orderByFail").click(function(){$("#dataLoad").show();});
$("#orderByRate").click(function(){$("#dataLoad").show();});
$("#stats").change(function(){$("#dataLoad").show();}); //change
$("#indexPage").click(function(){$("#dataLoad").show();});
}
);
<select name="dictFilter.dictStatus" id="stats" onchange="javascript:location.href=this.value">
<option selected="selected" value="<%=basePath%>acauthinfo/authDefault.jsp?pageNum=1&StartTime=<%=pager.getStartTime()%>&field=<%=pager.getField()%>&sortOrder=<%=pager.getSortOrder()%>&EndTime=<%=pager.getEndTime()%>&pageSize=10" >每页10行</option>
<option selected="selected" value="<%=basePath%>acauthinfo/authDefault.jsp?pageNum=1&StartTime=<%=pager.getStartTime()%>&field=<%=pager.getField()%>&sortOrder=<%=pager.getSortOrder()%>&EndTime=<%=pager.getEndTime()%>&pageSize=20">每页20行</option>
<option selected="selected" value="<%=basePath%>acauthinfo/authDefault.jsp?pageNum=1&StartTime=<%=pager.getStartTime()%>&field=<%=pager.getField()%>&sortOrder=<%=pager.getSortOrder()%>&EndTime=<%=pager.getEndTime()%>&pageSize=30">每页30行</option>
<option selected="selected" value="">---请选择---</option>
</select>