响应回车和判断是否为数字的函数(可用于分页)
来源:互联网 发布:淘宝 买折扇推荐 编辑:程序博客网 时间:2024/06/06 08:58
响应回车和判断是否为数字的函数(可用于分页)
原文地址
<script language="javascript" type="text/javascript">
//分页处理函数
function check()
{
// 响应回车
if(event.keyCode == 13)
{
var currentPage = document.getElementById("currentPage");
var totalPage = document.getElementById("totalPage");
var flag = true;
if(isNaN(currentPage.value))
{
alert('请输入数字');
currentPage.value = "";
currentPage.focus();
return false;
}
else
{
//处理输入大于总页数
if(currentPage.value > totalPage.value)
currentPage.value = totalPage.value;
//处理小数或负数
if(currentPage.value <= 0)
currentPage.value = 1;
//跳转
window.location = "user.action?currentPage=" + currentPage.value;
currentPage.focus();
return true;
}
}
}
</script>
//分页处理函数
function check()
{
// 响应回车
if(event.keyCode == 13)
{
var currentPage = document.getElementById("currentPage");
var totalPage = document.getElementById("totalPage");
var flag = true;
if(isNaN(currentPage.value))
{
alert('请输入数字');
currentPage.value = "";
currentPage.focus();
return false;
}
else
{
//处理输入大于总页数
if(currentPage.value > totalPage.value)
currentPage.value = totalPage.value;
//处理小数或负数
if(currentPage.value <= 0)
currentPage.value = 1;
//跳转
window.location = "user.action?currentPage=" + currentPage.value;
currentPage.focus();
return true;
}
}
}
</script>
<input type="text" name="currentPage" size="2" onkeydown="return check();"/>
<!-- 保存总页数,用于javascript处理分页 -->
<input type="hidden" id="totalPage" value="<s:property value="#page.totalPage"/>" />
其中的totalPage是通过分页类算出来的. <!-- 保存总页数,用于javascript处理分页 -->
<input type="hidden" id="totalPage" value="<s:property value="#page.totalPage"/>" />
- 响应回车和判断是否为数字的函数(可用于分页)
- sqlserver判断是否为数字的函数
- sqlserver判断是否为数字的函数
- sqlserver 判断是否为数字的函数
- 经常使用的判断string是否为数字的函数
- C#判断是否为数字的两个函数
- java python oracle判断字符串是否为数字的函数
- Oracle 判断值是否为数字的函数
- 判断字段是否全部为数字函数
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- 判断是否为数字
- stop:0X000007B
- rtp/rtcp协议详解
- javascript去除字符串空格的函数
- Android 应用性能调试
- Android调用系统摄像头--使用MediaRecorder--1--预览(preview)功能
- 响应回车和判断是否为数字的函数(可用于分页)
- Linux下VNC Server的配置过程
- 验证表单的标准JavaScript
- 用javascript实现的tip效果
- Win7/Vista/xp共享文件夹权限解惑
- 标准的动态显示当前时间的JavaScript函数
- 8086_显示字符串
- Javascript动态创建控件
- 译 ADF View Object Performance Tuning Analysis