<script language="JavaScript">
<!--
function a(f){
var re=/\d*$/
var d=parseInt(f.action.match(re)[0]);
f.action=f.action.replace(re,d+=1)
}
//-->
</script>
<form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:a(this)" target="_blank">
 <input type="submit" value="开始检索" class="submit" name="submit">
</form>

解决方案 »

  1.   

    为什么不把search的值做成一个hidden类型呢?这样就很好处理了
      

  2.   

    不行的呀,第一次,点击的时候能加一,可是再次点击的时候,却是不能加了.
    请用做成用hidden又该怎么实现嘛. 能不能把代码写出来.谢谢
    <script language=JavaScript>
    <!--
    function newSearch(theForm) 
    {
                      var re=/\d*$/
    var d=parseInt(theForm.action.match(re)[0]);
    theForm.action=theForm.action.replace(re,d+=1)

     if(theForm.word.value == "")
    {
       alert("请您输入检索词!");
       theForm.word.focus();
       return (false);
    }}
    //-->
    </script>
    <form method="POST" action="index.jsp?search=1" name=form1 onSubmit="javascript:return newSearch(this);"> <input type="submit" value="开始检索" class="submit" name="submit">
      

  3.   

    function window_onload()
    {
       document.form1.hidden1.value=2
    }
    function newSearch(theForm)
    {  
        var a=ParseInt(document.form1.hidden1.value)+1
        f.action="index.jsp?search=" + a.toString()
    }
      

  4.   

    下面是我把他整和后使用,可是跳出错误来,那位兄弟帮帮看看,是为什么,谢谢了.
    document.form1.hidden1.value=2   //为空或不是对象<script language=JavaScript>
    <!--
     function window_onload()
      {
           document.form1.hidden1.value=2   //跳出网页脚本错误,说这为空或不是对象
       }
     function newSearch(theForm) 
      {
           var a=ParseInt(document.form1.hidden1.value)+1
           theForm.action="index.jsp?search=" + a.toString()

     if(theForm.word.value == "")
      {
           alert("请您输入检索词!");
           theForm.word.focus();
           return (false);
      }
    }//-->
    </script><form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:return newSearch(this);">
     <input type="text" name="word" width=100>
    <input type="submit" value="开始检索"  name="submit">
    </form>
      

  5.   

    何必搞那么复杂呢?
    <script>
    var a=1;
    var str="index.jsp?search=";
    </script>
    <form method="POST" name=form1 onSubmit="document.form1.action=str+a;">
    <input type="button" value="开始检索"  name="submit" onclick="a++;">
    </form>
      

  6.   

    试了一下楼上的,不行,不知道那个兄弟在我下面的程序里修改一下,谢谢,快急死了我了.
    <script language=JavaScript>
    <!--
    function newSearch(theForm) 
    {
    var a=1;
    var str="index.jsp?search=";
    document.form1.action=str+a;

     if(theForm.word.value == "")
    {
       alert("请您输入检索词!");
       theForm.word.focus();
       return (false);
    }}
    //-->
    </script>
    <form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:return newSearch(this);">
    <input type="text" name="word" class=input width=100>
     <input type="button" value="开始检索"  name="submit" onclick="a++;">
    </form>
      

  7.   

    function newSearch(theForm)
    {  
        var a=ParseInt(document.form1.hidden1.value)+1
        form1.action="index.jsp?search=" + a.toString()
    }你没有再html中加
    <INPUT type="hidden" value=2 name="hidden1">
      

  8.   

    楼上的你好,我试了下面的方法,还是不行的,跳出错误了<script language=JavaScript>
    <!--
     function window_onload()
      {
           document.form1.hidden1.value=2   //跳出网页脚本错误,说这为空或不是对象
       }
     function newSearch(theForm) 
      {
             var a=ParseInt(document.form1.hidden1.value)+1
         form1.action="index.jsp?search=" + a.toString()

     if(theForm.word.value == "")
      {
           alert("请您输入检索词!");
           theForm.word.focus();
           return (false);
      }
    }//-->
    </script>
    <INPUT type="hidden" value=2 name="hidden1">
    <form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:return newSearch(this);">
    <input type="submit" value="开始检索" class="submit" name="submit">
    </form>
      

  9.   

    你要把下面这句放到<form>标识里。也就是改为:
    <form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:return newSearch(this);">
    <INPUT type="hidden" value=2 name="hidden1">
    <input type="submit" value="开始检索" class="submit" name="submit">
    </form>
      

  10.   

    阿信的代码是可以的啊,怎么会不行。
    我把他的测试过,全部代码如下:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <script language="JavaScript">
    <!--
    function a(f){
    var re=/\d*$/
    var d=parseInt(f.action.match(re)[0]);
    alert(d);
    f.action=f.action.replace(re,d+=1)
    }
    //-->
    </script>
    <form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:a(this)" target="_blank">
     <input type="submit" value="开始检索" class="submit" name="submit">
      <input type="button" name="Submit" value="测试" onClick="a(window.document.form1);">
    </form>
    </body>
    </html>
      

  11.   

    超仔,
    你要把下面这句放到<form>标识里。也就是改为:
    <form method="POST" action="index.jsp?search=2" name=form1 onSubmit="javascript:return newSearch(this);">
    <INPUT type="hidden" value=2 name="hidden1">    //我把他放到里面,还是出错,缺少对象
    <input type="submit" value="开始检索" class="submit" name="submit">
    </form>
      

  12.   

    下面的是我用阿信的测试,只能让action="index.jsp?search=1"加到2,就再也不能加上去了,
    那位兄弟帮帮忙,看看是我把程序那里写错了,帮我改改,谢谢了,我快及死了
    <script language="JavaScript">
    <!--
    function newSearch(f){
    var re=/\d*$/
    var d=parseInt(f.action.match(re)[0]);
    //alert(d);             //测试这句话,数字按上加,没有问题,
    f.action=f.action.replace(re,d+=1)
          if(f.word.value == "")
           {
               alert("请您输入检索词!");
               f.word.focus();
               return (false);
           }
    }
    //-->
    </script><form method="POST" action="index.jsp?search=1" name=form1 onSubmit="javascript:return newSearch(this)">
     <input type="submit" value="开始检索" name="submit">
    </form>
      

  13.   

    <%@ page contentType="text/html; charset=GBK" %>
    <html>
    <head>
    <title>
    Jsp3
    </title>
    </head>
    <script  language="javascript">
    function ch(){
    form1.submit();
    }
    </script>
    <body>
    <%
    String s=request.getParameter("search");
    String  ss="http://localhost:8080/Jsp3.jsp?search=";
    if(s==null)
    {
      s="2";
    }
    else
    {
     int i=Integer.parseInt(s);
     i++;
     s=String.valueOf(i);
    }
    out.println(s);
    %>
    <form method="POST" name="form1"  action=<%=ss.concat(s)%>>
    <input type="submit" value="开始检索"  name="submit" onclick="ch()">
    </form>
    </body>
    </html>
      

  14.   

    <%@ page contentType="text/html; charset=GBK" %>
    <html>
    <head>
    <title>
    Jsp3
    </title>
    </head>
    <body>
    <%
    String s=request.getParameter("search");
    String  ss="http://localhost:8080/Jsp3.jsp?search=";
    if(s==null)
    {
      s="2";
    }
    else
    {
     int i=Integer.parseInt(s);
     i++;
     s=String.valueOf(i);
    }
    out.println(s);
    %>
    <form method="POST" name="form1"  action=<%=ss.concat(s)%>>
    <input type="submit" value="开始检索"  name="submit" >
    </form>
    </body>
    </html>
      

  15.   

    这个能运行,但把这个地址给固定死了.换了IP的话,就不行了.
    有没有不用固定IP,给个能自动识别IP的程序就好了,不用换了IP就得去改这个文件.
    String  ss="http://localhost:8080/Jsp3.jsp?search=";