title: Read data from Javascript dynamic input in node.js
body: <p>I need dynamic input fields for my node-js application. I need to populate a input text are for writing their cost names on a form. I found some javascript code on internet. It works perfectly but when i try to read data from body, i only have one value. What could be the reason?</p>
  <p>Here is my javascript code;</p>
  <pre><code>$(function () {
    var max_fields = 10; //maximum input boxes allowed
    var wrapper = $(&quot;.input_fields_wrap&quot;); //Fields wrapper
    var add_button = $(&quot;.add_field_button&quot;); //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&gt;&lt;input type=&quot;text&quot; name=&quot;generalCostName[]&quot; class=&quot;form-control&quot;/&gt;&lt;a href=&quot;#&quot; class=&quot;remove_field&quot;&gt;Remove&lt;/a&gt;&lt;/div&gt;'
        ); //add input box
      }
    });
  
    $(wrapper).on(&quot;click&quot;, &quot;.remove_field&quot;, function (e) {
      //user click on remove text
      e.preventDefault();
      $(this).parent(&quot;div&quot;).remove();
      x--;
    });
  });
  </code></pre>
  <p>here is the part of my ejs file;</p>
  <pre><code>&lt;div class=&quot;input_fields_wrap&quot;&gt;
     &lt;button class=&quot;add_field_button&quot;&gt;Add More Fields&lt;/button&gt;&lt;div&gt;
     &lt;input type=&quot;text&quot; name=&quot;generalCostName[]&quot; class=&quot;form-control&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>For example, i populate 2 more input fields and their values are &quot;Test1&quot;,&quot;Test2&quot; and  &quot;Test3&quot;. When i submit values to the node-js side, on the console( console.log(req.body.generalCostName) ) i only have Test1 value. What could be the reason?</p>