Tuesday, 10 January 2017

How to handle multiple submission in web page?

The simplest way to handle the multiple submit problem is to prevent it from happening. Below is a form, which includes a small amount of JavaScript. The embedded JavaScript remembers if the submit button was previously pressed. On a resubmit, an alert pops up and the form is not submitted again.

 <html>
 <input type="button" name="btnSubmit"
 value="Do Submit"
 onClick="checksubmitcount();">
 </td>
 </tr>
 </table>
 </form>

 <script language="javascript">
 var submitcount = 0;
 function checksubmitcount()
 {
  submitcount++;
  if (1 == submitcount )
  {
   document.Order.submit();
  }
  else
  {
   if ( 2 == submitcount)
    alert("You have already submitted  this form");
   else
    alert("You have submitted this form"
    + submitcount.toString()
    + " times already");
  }
 }
 </script>
 </body>
 </html>

No comments:

Post a Comment