title: How to disable upload button during file upload and append
body: <p>By fluke I realise an issue which would cause a big problem with my application.</p>
  
  <p>I have my application here where it will upload videos. <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/InputTest2.php" rel="noreferrer">Application</a></p>
  
  <p>The problem I have is that if you upload a video and then click on the <code>Add Question</code> button to append another file input in a new row, the <code>Upload</code> button in the new row is not disabled, this means that you can upload multiple files which I do not want as it will stop the first file uploading to stop uploading and potentially system ould crash if users try to upload large multiple files. My question is that if I click on the <code>Add Question</code> button , if a file is uploading, then the upload button in the appended row(s) should be disabled until upload is finished?</p>
  
  <p>To use app follow steps below:</p>
  
  <ol>
  <li><p>Click on <code>Add Question</code> twice to append 2 new table rows. In each table row you will see a file input.</p></li>
  <li><p>In file input in row 1 select a video (I select a decent size video so that file is uploading while you complete other steps) and click on <code>Upload</code> to upload video. You will now see that the <code>Upload</code> buttons are disabled while video is uploading</p></li>
  <li><p>Now while video is uploading click on <code>Add Question</code> button again to append another row. Now you will see that the <code>Upload</code> button in the newly appended row is not disabled while the file is uploading. I want this button and other upload buttons which are appended to be disabled if a file is uploading.</p></li>
  </ol>
  
  <p>Below is Relevant code where it appends the table rows from the <code>Add Question</code> button:</p>
  
  <pre><code>function GetFormVideoCount(){ 
    return $('.videouploadform').length + 1;
  }
  
  
  var qnum = 1;
  var qremain = 5;
  
  function insertQuestion(form) {   
  
      if (qnum &gt; 5) {
      return;
  }
  
  
      var $tbody = $('#qandatbl_onthefly &gt; tbody');
      var $tr = $("&lt;tr class='optionAndAnswer' align='center'&gt;");
      var $video = $("&lt;td width='17%' class='video'&gt;&lt;/td&gt;"); 
  
                $('.num_questions').each( function() {
  
      var $fileVideo = $("&lt;form action='videoupload.php' method='post' enctype='multipart/form-data' target='upload_target_video' onsubmit='return videoClickHandler(this);' class='videouploadform' &gt;" + 
      "&lt;p class='videof1_upload_form'&gt;&lt;label&gt;" + 
      "Video File: &lt;input name='fileVideo' type='file' class='fileVideo' /&gt;&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;&lt;label class='videolbl'&gt;" +  
      "&lt;input type='submit' name='submitVideoBtn' class='sbtnvideo' value='Upload' /&gt;&lt;/label&gt;" + 
      "&lt;p class='videof1_upload_process' align='center'&gt;Loading...&lt;br/&gt;&lt;img src='Images/loader.gif' /&gt;&lt;/p&gt;" +
      "&lt;input type='hidden' class='numvideo' name='numvideo' value='" + GetFormVideoCount() + "' /&gt;" + &lt;/p&gt;" +
      "&lt;iframe class='upload_target_video' name='upload_target_video' src='/' style='width:0px;height:0px;border:0px;solid;#fff;'&gt;&lt;/iframe&gt;&lt;/form&gt;"); 
  
      $video.append($fileVideo);
  
  
      $tr.append($video);  
      $tbody.append($tr); 
  
  
  }
  </code></pre>
  
  <p>Below is relevant code where when it starts the file's uploading process and where it disables the upload buttons in rows which are already appended:</p>
  
  <pre><code>   function startVideoUpload(videouploadform){
  
               sourceVideoForm = videouploadform;
  
              $(".sbtnvideo").attr("disabled", "disabled");
  
  
      }); 
  
            return true;
      }
  </code></pre>
  
  <p>Below is relevant code for function when uploading has finished:</p>
  
  <pre><code>function stopVideoUpload(success, videoID, videofilename){
  
  
        $(".sbtnvideo").removeAttr("disabled");
  
  
        return true;   
  }
  </code></pre>
  
  <p>Below is video upload click handler:</p>
  
  <pre><code>   function videoClickHandler(videouploadform){ 
        if(videoValidation(videouploadform)){ 
            window.lastUploadVideoIndex = $('.videouploadform').index(videouploadform);
            return startVideoUpload(videouploadform); 
        } 
        return false;
    }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>function startVideoUpload(videouploadform){
  
  
                 $(".sbtnvideo").click(function(event){
                 $(".sbtnvideo").attr("disabled", "disabled");
      event.preventDefault();
      });
  
         return true;   
      }
  
      function stopVideoUpload(success, videoID, videofilename){
  
  
                  $(".sbtnvideo").click(function(event){
                  $(".sbtnvideo").removeAttr("disabled");
      return true;
  });
  
  
            return true;   
      }
  </code></pre>