title: get length of input array field in html form using javascript
body: <p>I need the array length</p>
  
  <p><strong>html code</strong></p>
  
  <pre><code>&lt;form action="#" method="POST" name="form1"&gt;
      &lt;table class="table table-hover"&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Date&lt;/th&gt;
              &lt;th&gt;&amp;nbsp;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr id="profile_1_"&gt;
                  &lt;td&gt;&lt;a href="http://localhost:8000/company/jobseeker/profile/1" target="_blank"&gt;Geethu&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;2017-05-10 06:20:35&lt;/td&gt;
                  &lt;td&gt;&lt;button type="button" class="btn btn-danger btn-xs remove-profile" id="1"&gt;Remove&lt;/button&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="hidden" name="candidate[1]"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                    &lt;tr id="profile_2_"&gt;
                  &lt;td&gt;&lt;a href="http://localhost:8000/company/jobseeker/profile/2" target="_blank"&gt;John&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;2017-05-10 09:04:12&lt;/td&gt;
                  &lt;td&gt;&lt;button type="button" class="btn btn-danger btn-xs remove-profile" id="2"&gt;Remove&lt;/button&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="hidden" name="candidate[2]"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;            
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to get the count of candidate array each time i remove a table row.</p>
  
  <p><strong>javascript code</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(".remove-profile").click(function(){
          alert($('input[name="candidate[]"]').length);
          var id = $(this).attr('id');
          $('#profile_'+id).remove();
          getTotal();
      });
  
      function getTotal(){
        var count = $('input[name="candidate[]"]').length;
        var total = count * 10 ;
        $('input[name=total]').val(total);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>but I'am getting count as 0 always.</p>