title: Dynamically Add Form Fields and Update Field Value
body: <p>I have a form that you can add fields: <a href="http://jsfiddle.net/ytrkqr6a/2/" rel="nofollow">http://jsfiddle.net/ytrkqr6a/2/</a></p>
  
  <pre><code>    $(document).ready(function() {
      var max_fields      = 32; //maximum input boxes allowed
      var wrapper         = $(".cameras"); //Fields wrapper
      var add_button      = $(".add-camera"); //Add button ID
  
      var x = 1; //initlal text box count
      $(add_button).click(function(e){ //on add input button click
          e.preventDefault();
          if(x &lt; max_fields){ //max input box allowed
              x++; //text box increment
              $(wrapper).append('&lt;div class="form-group"&gt;&lt;input type="text" name="camera '+ x +'" value="Camera '+ x +'" placeholder="Camera '+ x +'" class="form-control cameras" readonly /&gt; &lt;a href="#" class="remove-camera"&gt;Remove&lt;/a&gt;&lt;/div&gt;'); //add input box
          }
      });
  
      $(wrapper).on("click",".remove-camera", function(e){ //user click on remove text
          e.preventDefault(); $(this).parent('div').remove(); x--;
      })
  });
  &lt;div class="cameras"&gt;
              &lt;div class="camera-field"&gt;&lt;button class="add-camera btn btn-primary"&gt;+ Add Camera&lt;/button&gt;&lt;/div&gt;
              &lt;div style="clear:both;"&gt;&lt;/div&gt;
  
              &lt;div class="form-group"&gt;&lt;input type="text" name="camera" value="" placeholder="Camera 1" class="form-control cameras" readonly /&gt;&lt;/div&gt;
  
              &lt;/div&gt;
  </code></pre>
  
  <p>Everything works fine adding fields, but where I'm hung up is when you remove one of the fields then numerical order gets off.. how do I make it update the remaining fields to stay in proper numerical order each time you add or remove a field:</p>
  
  <p>Camera 1 <br>
  Camera 2 <br>
  Camera 3 <br>
  etc...</p>
  
  <p>Thanks ahead of time!</p>