One click on a form submits twice!

Discussion in 'HTML' started by Ken Adams, Mar 16, 2005.

  1. Ken Adams

    Ken Adams Guest

    Basically I have a form that looks something like the following: The form is
    contained in the file subscriptAdd.jsp so I want to submit the form to
    itself and do some jsp validation after it's submitted, but for some reason
    I noticed that two request are being make on each click. Any suggestions.
    Thanks

    <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
    method="POST" onsubmit="return checker()">

    <input type="submit" value="Submit">

    </form>
    Ken Adams, Mar 16, 2005
    #1
    1. Advertising

  2. Ken Adams

    Guest

    Ken Adams wrote:
    > Basically I have a form that looks something like the following: The

    form is
    > contained in the file subscriptAdd.jsp so I want to submit the form

    to
    > itself and do some jsp validation after it's submitted, but for some

    reason
    > I noticed that two request are being make on each click. Any

    suggestions.
    > Thanks
    >
    > <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp")

    %>"
    > method="POST" onsubmit="return checker()">
    >
    > <input type="submit" value="Submit">
    >
    > </form>


    What does checker() do? Odds are that's the problem. What does
    subscriptAdd.jps do? Mind you, you haven't posted enough of your code
    for anyone to do more than guess the answer. Thinking about it, don't
    post your code here - provide a URL instead.

    --
    Hywel
    , Mar 16, 2005
    #2
    1. Advertising

  3. Ken Adams

    Augustus Guest

    "Ken Adams" <> wrote in message
    news:noRZd.37843$ZO2.11322@edtnps84...
    > Basically I have a form that looks something like the following: The form

    is
    > contained in the file subscriptAdd.jsp so I want to submit the form to
    > itself and do some jsp validation after it's submitted, but for some

    reason
    > I noticed that two request are being make on each click. Any suggestions.
    > Thanks
    >
    > <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
    > method="POST" onsubmit="return checker()">
    >
    > <input type="submit" value="Submit">
    >
    > </form>
    >


    saying that it looks "something like the following" and then including a
    tiny snippet of code isn't going to be much for people trying to help you
    (we'll have to ask "is this the actual code? how "like" the real thing is
    the above? Is there something else that could be causing the problem?
    Whats in 'checker()'?). A working link to your web page with the form would
    be much better.

    Odds are your problem is the part:
    onsubmit="return checker()"

    instead you probably want:
    onsubmit="return checker(); return false"

    That might fix it up
    Augustus, Mar 16, 2005
    #3
  4. Ken Adams

    Lachlan Hunt Guest

    Ken Adams wrote:
    > Basically I have a form that looks something like the following: The form is
    > contained in the file subscriptAdd.jsp so I want to submit the form to
    > itself and do some jsp validation after it's submitted, but for some reason
    > I noticed that two request are being make on each click. Any suggestions.
    > Thanks


    URL?

    > <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
    > method="POST" onsubmit="return checker()">


    You should generally include the output HTML, not your JSP when asking
    about an HTML related question. Though, in this case it appears as
    though the output will be action="subscriptAdd.jsp".

    There is no reason why that code would make anything submit twice,
    unless the JavaScript function has something to do with it. Check that
    function checker() isn't doing any unnecessary form submissions. Other
    than that, it's most likely an error with your JSP back end coding.

    --
    Lachlan Hunt
    http://lachy.id.au/
    http://GetFirefox.com/ Rediscover the Web
    http://GetThunderbird.com/ Reclaim your Inbox
    Lachlan Hunt, Mar 19, 2005
    #4
  5. Ken Adams

    Sagar@1

    Joined:
    Jan 22, 2013
    Messages:
    1
    jsp form submtting twice

    I am facing the same issue. My jsp page is like this.

    <form method="post" name="MyForm" action="/servlet/ibs.servlets.MyServlet">


    <TR id="buttons"><td align="right" colspan=2 class="clsdetsub"><A class=clsinfo href="javascript:yesPage()">Confirm</A>

    function yesPage()
    {
    var tb1 = document.getElementById('buttons');
    var tb2 = document.getElementById('aftersubmit');
    tb1.style.visibility = "hidden";
    tb2.style.visibility = "visible";
    document.MyForm.submit();
    };

    Sometimes click on Confirm, submits the form twice. How it is happening? Wat is the solution to resolve this? Pls help.....
    Sagar@1, Jan 22, 2013
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert V
    Replies:
    1
    Views:
    1,174
    Jeremy Fluhmann
    Jul 21, 2003
  2. mike parr
    Replies:
    1
    Views:
    465
    Marina
    May 20, 2004
  3. Umesh

    Page Submits twice

    Umesh, Feb 24, 2006, in forum: HTML
    Replies:
    3
    Views:
    605
    Alan J. Flavell
    Feb 24, 2006
  4. Umesh

    Page Submits Twice

    Umesh, Feb 24, 2006, in forum: ASP General
    Replies:
    5
    Views:
    140
    Evertjan.
    Feb 25, 2006
  5. Daniish
    Replies:
    2
    Views:
    242
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page