如果是定死的就用数据
这是我写的一个例子,数据是定死的,我这里只有两个下拉列表,三个的其实道理一样
<html>
<head>
<meta http-equiv=content-type content="text/htmlcharset=GBK">
<script language="JavaScript" type="text/javascript">
<!--
// 初始时定义相关数组
var provinces = ["吉林", "辽宁", "黑龙江", "江苏", "山东"]
var jiLin = ["长春", "吉林", "白城", "白山"]
var liaoNing = ["沈阳", "大连", "鞍山"]
var heiLongJiang = ["哈尔滨", "佳木斯", "牡丹江", "齐齐哈尔"]
var jiangSu = ["南京", "苏州", "无锡", "常州", "徐州"]
var shanDong = ["济南", "烟台", "青岛", "威海"]
var allProvinces = ["", jiLin, liaoNing, heiLongJiang, jiangSu, shanDong]
// 取得用户选择的省
function selectProvince(obj){
var province = obj.value
if(parseInt(province) >= allProvinces.length)
return
addCity(allProvinces[province])
}
// 向城市复选框中添加数据
function addCity(province){
var citys = document.all.city
citys.options.length = 1
document.all.picture.src = "images\\城市.jpg"
if(province == "") return
for(var i=0i<province.lengthi++){
citys.add(new Option(province[i], i+1, false, false))
}
}
// 选择城市列出介绍
function selectCity(obj){
var city = obj.value
document.all.picture.src = "images\\" + obj.options[parseInt(city)].text + ".jpg"
}
-->
</script>
</head>
<body>
<!--province-->
<select id="sheng" onchange="selectProvince(this)">
<option value="0" selected = true>选择省</option>
</select>
<!--city-->
<select id="city" onchange="selectCity(this)">
<option value="0" selected = true>城市</option>
</select>
<br>
<!--picture-->
<table border=15 style=border-style:ridge width=360 height=300>
<tr valign=top>
<td>
<img src="images\\城市.jpg" id="picture" name="picture" width=360 height=300/>
</td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
// 初始化省
var obj = document.all.sheng
for(i=0 i<5 i++){
obj.add(new Option( provinces[i], i + 1, false, false))
}
-->
</script>
</body>
</html>
我已经把分页做好了,剩下的你应该可以解决!
var ObjPage = {}///总记录数
ObjPage.RecordCount = 0
///总共页数
ObjPage.PageCount = 0
///当前页数, 1为第一页
ObjPage.PageIndex = 1
///每页记录数
ObjPage.PageSize = 3
///生成分页按钮
ObjPage.Fun = function () {
var sb = ''
if (ObjPage.PageIndex <= 1) {
sb += '<span id="spanFirst" val="0">首页</span> <span id="spanPre" val="0">上一页</span>'
} else {
sb += '<span id="spanFirst" val="1">首页</span> <span id="spanPre" val="' + (ObjPage.PageIndex - 1) + '">上一页</span>'
}
if (ObjPage.PageIndex >= ObjPage.PageCount) {
sb += '<span id="spanNext" val="0">下一页</span> <span id="spanLast" val="0">尾页</span>'
} else {
sb += '<span id="spanNext" val="' + (ObjPage.PageIndex + 1) + '">下一页</span> <span id="spanLast" val="' + (ObjPage.PageCount) + '">尾页</span>'
}
sb += '第<span id="spanPageNum">' + ObjPage.PageIndex + '</span>页/共<span id="spanTotalPage">' + ObjPage.PageCount + '</span>页'
$(".pagess").html(sb)
}
///初始化数据
ObjPage.Load = function () {
var PicList = $(".PicList")
var dd_length = PicList.find("dd").length
ObjPage.RecordCount = dd_length
var PageCount = dd_length % ObjPage.PageSize>0?1:0
ObjPage.PageCount = parseInt(dd_length / ObjPage.PageSize) + PageCount
ObjPage.Fun()
}
$(function () {
ObjPage.Load()
$("#spanPre,#spanNext,#spanLast,#spanFirst").live("click", function () {
var v_val = parseInt($(this).attr("val"))
if (v_val == 0) {
var v_id = $(this).attr("id") alert(v_id)
switch (v_id) {
case "spanLast":
alert("已经是尾页")
break
case "spanFirst":
alert("已经是首页")
break
}
return
}
ObjPage.PageIndex = v_val
ObjPage.Fun()
})
})