Avoid multiple clicks to submit a form in IE...Works well in chrome...

Avoid multiple clicks to submit a form in IE...Works well in chrome...

Please find below file code where multiple file upload functionality is given. On click of upload link it opens input file browser window where we select file and then click on submit.

In chrome, submit button submits the form on first click but In IE, it does not submit the form on first click.

In IE, If we select one file using upload link then submit button submits the form in second click.

If we select two file then it submits the form in 3rd click and accordingly.

Please let me know how to stop this event chain to submit in one click.

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <meta charset="UTF-8">
  6. <title>Title of the document</title>
  7. </head>

  8. <body>
  9.     <form method="post" action="submitted">
  10.         <table>
  11.             <tr>
  12.                 <td>
  13.                     <input type="file" name="inputFile" />
  14.                     <a class="uploadLink" name="upload" style="cursor: pointer;" onclick="selectInputFile(this)">Upload</a>
  15.                 </td>
  16.             </tr>
  17.             <tr>
  18.                 <td>
  19.                     <input type="file" name="inputFile" />
  20.                     <a class="uploadLink" name="upload" style="cursor: pointer;" onclick="selectInputFile(this)">Upload</a>
  21.                 </td>
  22.             </tr>
  23.             <tr>
  24.                 <td>
  25.                     <input type="file" name="inputFile" />
  26.                     <a class="uploadLink" name="upload" style="cursor: pointer;" onclick="selectInputFile(this)">Upload</a>
  27.                 </td>
  28.             </tr>
  29.             <tr>
  30.                 <td>
  31.                     <input type="file" name="inputFile" />
  32.                     <a class="uploadLink" name="upload" style="cursor: pointer;" onclick="selectInputFile(this)">Upload</a>
  33.                 </td>
  34.             </tr>
  35.             <tr>
  36.                 <td>
  37.                     <input type="file" name="inputFile" />
  38.                     <a class="uploadLink" name="upload" style="cursor: pointer;" onclick="selectInputFile(this)">Upload</a>
  39.                 </td>
  40.             </tr>
  41.             <tr>
  42.                 <td>
  43.                     <input type="submit" value="Submit" />
  44.                 </td>
  45.             </tr>
  46.         </table>
  47.     </form>
  48. </body>

  49. <script type="text/javascript">
  50.     function selectInputFile(uploadLink) {
  51.         $(uploadLink).prev().trigger('click');
  52.     }

  53.     $(document).ready(function(){
  54.         $("form").on("submit", function(e){
  55.             e.stopPropagation();
  56.         });
  57.     });
  58. </script>

  59. </html>