Home > Web Front-end > JS Tutorial > body text

Pass value js on the starting page, study and learn it when you have time_javascript skills

WBOY
Release: 2016-05-16 18:35:45
Original
966 people have browsed it
Copy code The code is as follows:

<script> <br>function ChangeParam(name, value) { <br>var url = window.location.href; <br>var newUrl = ""; <br>var reg = new RegExp("(^|)" name "=([^&]*)(|$) "); <br>var tmp = name "=" value; <br>if (url.match(reg) != null) { <br>newUrl = url.replace(eval(reg), tmp); <br>} <br>else { <br>if (url.match("[?]")) { <br>newUrl = url "&" tmp; <br>} <br>else { <br>newUrl = url "?" tmp; <br>} <br>} <br>//If the category is changed, start from page 1<br>if (name != "PageIndex") { <br>reg = new RegExp( "(^|)PageIndex=([^&]*)(|$)"); <br>tmp = "PageIndex=1"; <br>if (newUrl.match(reg) != null) { <br>newUrl = newUrl.replace(eval(reg), tmp); <br>} <br>} <br>location.href = newUrl; <br>} <br>function QueryMonthTicket() <br>{ <br> if($("selectM")!=null && $("selectY")!=null) <br>{ <br>var month=$("selectY").value $("selectM").value; <br>ChangeParam("Month",month); <br>} <br>} <br><br>function GoPage() <br>{ <br>var page=$("txtPage").value.trim( ); <br>if(page.length===0){ <br>alert("Please enter the page number"); <br>return false; <br>}; <br>var strNum = '1234567890'; <br>var isNum = true; <br>for(var i=0;i<page.length;i =1){ <BR>var c = page.charAt(i); <BR>if(strNum.indexOf (c) < 0){ <BR>isNum = false; <BR>break; <BR>}; <BR>}; <BR>if(isNum){ <BR>if(parseInt(page)>parseInt (initTotalPage)){ <br>alert("The number of pages you entered exceeds the total number of pages, please re-enter! "); <br>return false; <br>}; <br>ChangeParam("PageIndex",page); <br>}else alert('The information you entered is wrong, please re-enter!'); <br>} <br><br>function GoEnter(evt){ <br>evt=evt||window.event; <br>if(evt && evt.keyCode == 13) return GoPage(); <br>}; <br></script>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template