版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创!
恰饭广告
更新中…
function transformToJson(register) { var register = $("#" + register); //返回字符串xxx=xxx&yyy=yyy; var formData = register.serialize(); // 返回的是json数组[{xxx:xxx},{yyy:yyy}] formData = register.serializeArray(); var obj = {} for (var i in formData) { /*[{"name":"user","value":"hpc"},{"name":"pwd","value":"123"},{"name":"sex","value":"M"},{"name":"age","value":"100"},{"name":"phone","value":"13011112222"},{"name":"email","value":"xxx@xxx.com"}] */ //下标为的i的name做为json对象的key,下标为的i的value做为json对象的value obj[formData[i].name] = formData[i]['value']; } return obj; } //获取地址栏参数 function getUrlParms(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } //li标签分页 传入ul的id //<ul id="all"><li></li></ul> var pageall; var pageno; var pagesize; var a; var zz; function allpage(ulid) { a = document.getElementById(ulid).getElementsByTagName("li"); zz = new Array(a.length); for (var i = 0; i < a.length; i++) { zz[i] = a[i].innerHTML; } //div的字符串数组付给zz pageno = 1; //当前页 pagesize = 8; //每页多少条信息 if (zz.length % pagesize == 0) { pageall = zz.length / pagesize; } else { pageall = parseInt(zz.length / pagesize) + 1; } //一共多少页 change(1); } function change(e) { pageno = e; if (e < 1) { //如果输入页<1页 e = 1; pageno = 1;//就等于第1页 , 当前页为1 } if (e > pageall) { //如果输入页大于最大页 e = pageall; pageno = pageall; //输入页和当前页都=最大页 } document.getElementById("all").innerHTML = ""//全部清空 for (var i = 0; i < pagesize; i++) { var div = document.createElement("li")//建立div对象 div.innerHTML = zz[(e - 1) * pagesize + i]//建立显示元素 document.getElementById("all").appendChild(div)//加入all中 if (zz[(e - 1) * pagesize + i + 1] == null) break;//超出范围跳出 } var ye = ""; for (var j = 1; j <= pageall; j++) { if (e == j) { ye = ye + "<span><a href='#' onClick='change(" + j + ")' style='color:#FF0000'>" + j + "</a></span> " } else { ye = ye + "<a href='#' onClick='change(" + j + ")'>" + j + "</a> " } } document.getElementById("a1").innerHTML = pageall; document.getElementById("a2").innerHTML = pageno; //document.getElementById("a3").innerHTML=ye; } function tz() { var pagenum = document.getElementById("pagenum").value; if (pagenum == 0 || pagenum == null) { pagenum = 1; } change(pagenum); } //li分页html /** <div class="pagination" v-if="doctor!=null"> <span class="disabled">第</span> <span id="a2">1</span> <span>/</span> <span id="a1">3</span> <span class="disabled">页</span> <span class="disabled" title="上一页" onClick="change(--pageno)">上一页</span> <span onClick="change(++pageno)" class="disabled">下一页</span> <input type="button" value="跳转至" onclick="tz()" class="skip"><input type="text" id="pagenum" class="pageNum"><input type="button" value="页" class="page"> </div> */ //li分页栏css /** .pagination{ text-align: center;font-size: 16px;padding: 10px 0;display:inline-block;width: 1000px;margin-left: -3em} .pagination a,.pagination span,.pagination input{display: inline-block;padding: 0 10px;height: 28px;line-height: 28px;border: 1px solid #ddd;border-radius: 4px;text-decoration: none;color: #999;cursor: pointer; margin-right:5px;} .pagination a:hover:not(.disabled):not(.current),.pagination span:hover:not(.disabled):not(.current){color:#f04848} .pagination a.disabled,.pagination span.disabled,.pagination .skip,.pagination .page{color: #bfbfbf; background: #f5f5f5;border: 1px solid #ddd;} .pagination a.current,.pagination span.current{color: #fff;background: #f04848;border: 1px solid #f04848;} .pagination .pageNum{ width: 35px; } */ //传入表格id和每页展示量 //pagetion("table",10); var numCount; //数据总数量 var columnsCounts; //数据列数量 var pageCount; //每页显示的数量 var pageNum; //总页数 var currPageNum; //当前页数 //页面标签变量 var blockTable; var preSpan; var firstSpan; var nextSpan; var lastSpan; var pageNumSpan; var currPageSpan; function pagetion(tableId, allPage) { //页面标签变量 blockTable = document.getElementById(tableId); preSpan = document.getElementById("spanPre"); firstSpan = document.getElementById("spanFirst"); nextSpan = document.getElementById("spanNext"); lastSpan = document.getElementById("spanLast"); pageNumSpan = document.getElementById("spanTotalPage"); currPageSpan = document.getElementById("spanPageNum"); numCount = document.getElementById(tableId).rows.length - 1; //取table的行数作为数据总数量(减去标题行1) columnsCounts = blockTable.rows[0].cells.length; pageCount = allPage; pageNum = parseInt(numCount / pageCount); if (0 != numCount % pageCount) { pageNum += 1; } firstPage(); } function firstPage() { hide(); currPageNum = 1; showCurrPage(currPageNum); showTotalPage(); for (i = 1; i < pageCount + 1; i++) { blockTable.rows[i].style.display = ""; } firstText(); preText(); nextLink(); lastLink(); } function prePage() { hide(); currPageNum--; showCurrPage(currPageNum); showTotalPage(); var firstR = firstRow(currPageNum); var lastR = lastRow(firstR); for (i = firstR; i < lastR; i++) { blockTable.rows[i].style.display = ""; } if (1 == currPageNum) { firstText(); preText(); nextLink(); lastLink(); } else if (pageNum == currPageNum) { preLink(); firstLink(); nextText(); lastText(); } else { firstLink(); preLink(); nextLink(); lastLink(); } } function nextPage() { hide(); currPageNum++; showCurrPage(currPageNum); showTotalPage(); var firstR = firstRow(currPageNum); var lastR = lastRow(firstR); for (i = firstR; i < lastR; i++) { blockTable.rows[i].style.display = ""; } if (1 == currPageNum) { firstText(); preText(); nextLink(); lastLink(); } else if (pageNum == currPageNum) { preLink(); firstLink(); nextText(); lastText(); } else { firstLink(); preLink(); nextLink(); lastLink(); } } function lastPage() { hide(); currPageNum = pageNum; showCurrPage(currPageNum); showTotalPage(); var firstR = firstRow(currPageNum); for (i = firstR; i < numCount + 1; i++) { blockTable.rows[i].style.display = ""; } firstLink(); preLink(); nextText(); lastText(); } // 计算将要显示的页面的首行和尾行 function firstRow(currPageNum) { return pageCount * (currPageNum - 1) + 1; } function lastRow(firstRow) { var lastRow = firstRow + pageCount; if (lastRow > numCount + 1) { lastRow = numCount + 1; } return lastRow; } function showCurrPage(cpn) { currPageSpan.innerHTML = cpn; } function showTotalPage() { pageNumSpan.innerHTML = pageNum; } //隐藏所有行 function hide() { for (var i = 1; i < numCount + 1; i++) { blockTable.rows[i].style.display = "none"; } } //控制首页等功能的显示与不显示 function firstLink() { firstSpan.innerHTML = "<a href='javascript:firstPage();'>首页</a>"; } function firstText() { firstSpan.innerHTML = "首页"; } function preLink() { preSpan.innerHTML = "<a href='javascript:prePage();'>上一页</a>"; } function preText() { preSpan.innerHTML = "上一页"; } function nextLink() { nextSpan.innerHTML = "<a href='javascript:nextPage();'>下一页</a>"; } function nextText() { nextSpan.innerHTML = "下一页"; } function lastLink() { lastSpan.innerHTML = "<a href='javascript:lastPage();'>尾页</a>"; } function lastText() { lastSpan.innerHTML = "尾页"; } //table分页栏html /** <div id="pagiDiv" align="right" style="width:1200px"> <span id="spanFirst">首页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span> <span id="spanLast">尾页</span> 第 <span id="spanPageNum"></span> 页/共 <span id="spanTotalPage"></span> 页 </div> */ //table表格html /** <table class="table table-bordered" id="table"> <tr> <td>序号</td> <td>编号</td> <td>姓名</td> <td>操作</td> </tr> <tr> <td></td> <td></td> <td></td> <td> <button class="btn btn-info btn-sm" data-toggle="modal" data-target="#editModal">编辑</button> </td> </tr> </table> */ //判断浏览器是否支持cookie function checkCookie() { if (window.navigator.cookieEnabled) return true; else { alert("浏览器配置错误,Cookie不可用!"); return false; } } //判断是否为ie function isIE() { if (!!window.ActiveXObject || "ActiveXObject" in window) return true; else return false; }
原文链接:https://www.idaobin.com/archives/2129.html
让我恰个饭吧.ヘ( ̄ω ̄ヘ)
恰饭广告