开发者社区 问答 正文

document.getElementById()怎么使用

下面的代码应该怎么修改才能实现上一页、下一页、首页功能,为什么每次都是传到首页?

 <script language="javascript">
   function go(num){
      document.getElementById("cp").value = num;
      document.spform.submit();
   }
</script>
<form name="spform" action="<%=URL%>" method="post">
   <input type="button" value="首页" onclick="go(1)">
   <input type="button" value="上一页" onclick="go(<%=currentPage-1%>)">
   <input type="button" value="下一页" onclick="go(<%=currentPage+1%>)">
   <input type="button" value="尾页"> 
   <input type="hidden" id="cp" value="1">
</form>

展开
收起
小旋风柴进 2016-03-18 10:33:25 3046 分享 版权
1 条回答
写回答
取消 提交回答
  • 你的input少了name,没有name这个控件不会提交到服务器的,而且目测你的cp判断了没有值默认为第一页。。加上name="cp"

    <input type="hidden" id="cp" value="1" name="cp">

    2019-07-17 19:06:05
    赞同 展开评论
问答分类:
Go
问答地址: