求助一下。。js的图片变换功能改变页码显示格式

dolphin1984 2010-08-12 09:37:02
http://www.cnblogs.com/cloudgamer/archive/2008/05/23/1205642.html

上面网址中的页码是一个一个显示的,该如何实现,页码格式:“第n页/共m页”的格式??

求解
...全文
114 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Darcy杨 2010-08-12
  • 打赏
  • 举报
回复
这个跟JS没什么大关系吧,高级一点的分页组件都支持,比如CakePHP的pagination就可以实现。
dolphin1984 2010-08-12
  • 打赏
  • 举报
回复
。。。分全砸上了。。。。

有人么。。。

csdn现在怎么这么少人气啊。。。。。。。。。。
hoojo 2010-08-12
  • 打赏
  • 举报
回复

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>tab.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.subject {
border: 1px solid black;
width: 200px;
height: 200px;
}
.subject img {
width: 200px;
height: 200px;
}
</style>
<script type="text/javascript">
var imgAry = new Array();
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/ed9e7094af4f2677d1135e93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/2f78156fb7c8dae681cb4a93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/cf4013658b43f3ccf7365493.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/2f78156fb7c8dae681cb4a93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/ed9e7094af1f2677d0135e23.jpg");

window.onload = function () {
var oBox = document.getElementById("subjectBox");
var oShowId = document.getElementById("showId").value;
var subjectHtml = "";
for (var i = 1, len = imgAry.length; i <= len; i++) {
if (i == oShowId) {
subjectHtml += "<div id ='div_" + i + "' name='showDiv' style='display: block;' class='subject'>第" + i + "张/共" + len + "张<img src='" + imgAry[i-1] + "'/></div>"
} else {
subjectHtml += "<div id ='div_" + i + "' name='showDiv' style='display: none;' class='subject'>第" + i + "张/共" + len + "张<img src='" + imgAry[i-1] + "'/></div>"
}
}
oBox.innerHTML = subjectHtml;
showSubject2("next");
};

function setHide() {
var allDiv = document.getElementsByName("showDiv");
for (var i = 0; i < allDiv.length; i++) {
if (allDiv[i].style.display != "none") {
allDiv[i].style.display = "none";
}
}
}


//方法一:
function showSubject(flag) {
var oShowId = document.getElementById("showId").value;
var allDiv = document.getElementsByName("showDiv");
var len = allDiv.length;
//alert(oShowId + ":" + len);
setHide();//隐藏所有div
if (flag == "next") {
oShowId = eval(oShowId) + 1;
if (oShowId > len) {
oShowId = 1;
}
document.getElementById("div_" + oShowId).style.display = "block";
} else {
oShowId = eval(oShowId) - 1;
if (oShowId < 1) {
oShowId = len;
}
document.getElementById("div_" + oShowId).style.display = "block";
}
document.getElementById("showId").value = oShowId;
//setTimeout("showSubject('next')", 1000);//动态更换图片
}

//方法二:
function showSubject2(flag) {
var allDiv = document.getElementsByName("showDiv");
for (var i = 0, len = allDiv.length; i < len; i++) {
if (allDiv[i].style.display == "block") {
allDiv[i].style.display = "none";
if (flag == "next") {
if (i < len) {
i += 1;
}
if (i >= len) {
i = 0;
}
} else {
if (i > 0) {
i -= 1;
}
if (i <= 0) {
i = len - 1;
}
}
allDiv[i].style.display = "block";
break;
}
}
setTimeout("showSubject2('next')", 1000);//动态更换图片
}
</script>
</head>

<body>
方法1:
<input type="button" value="上" onclick="showSubject('prev')" />
<input type="button" value="下" onclick="showSubject('next')" />
<input type="hidden" id="showId" value="1" />
<br />
方法2:
<input type="button" value="上" onclick="showSubject2('prev')" />
<input type="button" value="下" onclick="showSubject2('next')" />
<div id="subjectBox"></div>
</body>
</html>

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧