This will happen when you are using <input type="submit"> and externally
calling the Javascript submit() function also. In this case submit button
automatically submits the form first time and second time the Javascript
function also submits the form.

To avoid this try using a simple button <input type="button"> and onClick
event of this button call your onCheck() function.

If you are stick to use submit button try using onSubmit event handler of
form to call the onCheck() function. And remove the submit() call from the
onCheck() function.

Regards
Chakradhar



On Fri, 5 Nov 2004 16:27:27 +0800, Edward King <[EMAIL PROTECTED]> wrote:

>I have two JSP page, there are one text and one button in index.jsp,when
write some information in text area and press Enter Key,this page will be
submit to other JSP page named cal.jsp,and in cal.jsp will print a
message "receive".when I run this index.jsp,and write some information in
textarea and then press Enter Key,I found this page is submit to
cal.jsp,but I found that cal.jsp print two receive,like follows:
>receive
>receive
>
>It should print "receive" once,but in fact it prints "receive" twice,why
occur this condition? I only submit once.
>My code is follows:
>
>index.jsp
>...
><script language="JavaScript">
><!--
>   function onCheck(){
>    if(strIsNull(document.thisform.code.value)==true){
>     alert("can't null");
>     return;
>    }
>    else{
>     document.thisform.action="cal.jsp";
>     document.thisform.submit();
>    }
>  }
>
>    function mykeydown() {
>     var whichkey=event.keyCode;
>     if (whichkey==13 || whichkey==10){
>       document.thisform.action="cal.jsp";
>       document.thisform.submit();
>     }
>    }
> -->
></script>
><form form name="thisform" method="post">
><input name="code" type="text" size="18" onkeydown="mykeydown()">
><a href="javascript:onCheck();"><img src="images/queding.gif" width="46"
height="19" border="0"></a>
></form>
>...
>
>
>cal.jsp
>...
><%
>    System.out.println("receive");
>%>
>
>Any idea will be appreciated!
>Best regards,
>Edward
>
>
>
>
>
>
> ==========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-
INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
>Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to