起点页面传值js,有空研究学习下
<script>
function ChangeParam(name, value) {
var url = window.location.href;
var newUrl = "";
var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
var tmp = name + "=" + value;
if (url.match(reg) != null) {
newUrl = url.replace(eval(reg), tmp);
}
else {
if (url.match("[\?]")) {
newUrl = url + "&" + tmp;
}
else {
newUrl = url + "?" + tmp;
}
}
//如果更换了类别,则从第1页开始
if (name != "PageIndex") {
reg = new RegExp("(^|)PageIndex=([^&]*)(|$)");
tmp = "PageIndex=1";
if (newUrl.match(reg) != null) {
newUrl = newUrl.replace(eval(reg), tmp);
}
}
location.href = newUrl;
}
function QueryMonthTicket()
{
if($("selectM")!=null && $("selectY")!=null)
{
var month=$("selectY").value+$("selectM").value;
ChangeParam("Month",month);
}
}
function GoPage()
{
var page=$("txtPage").value.trim();
if(page.length===0){
alert("请您输入页码");
return false;
};
var strNum = '1234567890';
var isNum = true;
for(var i=0;i<page.length;i+=1){
var c = page.charAt(i);
if(strNum.indexOf(c) < 0){
isNum = false;
break;
};
};
if(isNum){
if(parseInt(page)>parseInt(initTotalPage)){
alert("您输入的页数超过总页数,请重新输入!");
return false;
};
ChangeParam("PageIndex",page);
}else alert('您输入的信息有误,请重新输入!');
}
function GoEnter(evt){
evt=evt||window.event;
if(evt && evt.keyCode == 13) return GoPage();
};
</script>