title: Remove Form Field With Javascript
body: <p>So I Have Looked Through The Site Only To Not Find The Answer For My Particular Problem. I Am Pretty New To Writing Code And Am Trying To Figure Out How To Remove A Form Field After Its Been Added with Javascript. Here is the code. I would Greatly Appreciate Feedback/Solutions.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var counter = 1;
  var limit = 1000;
  function addInput(Favorites){
         if (counter == limit)  {
              alert("You have reached the limit of adding " + counter + " inputs");
         }
         else {
              var newdiv = document.createElement('div');
              newdiv.innerHTML = "&lt;br&gt;Favorite " + (counter + 1) + "&lt;input type='text' name='Favorites[]'&gt;&lt;input type ='button' value ='Remove'&gt;";
              document.getElementById(Favorites).appendChild(newdiv);
              counter++;
  
        }
  
        function removeInput(newdiv){
            document.getElementById('Favorites').removeChild(newdiv);
            counter - 1;
        }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  &lt;form&gt;
         &lt;div id="Favorites"&gt;
              Favorite 1&lt;input type="text" name="Favorites[]"&gt;
         &lt;/div&gt;
        &lt;input type="button" value="Add New Favorite" onClick="addInput('Favorites');"&gt;
        &lt;input type = "button" value = "Save Changes"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>