title: Replace all input fields in form with select - keeping the original name attribute of each element with jquery
body: <p>I have a form with some inputs like this:</p>
  <pre><code>&lt;div id=&quot;buttons&quot;&gt;
    &lt;label&gt;Quantity:&lt;/label&gt;
    &lt;input name=&quot;quantity_1&quot;  type=&quot;text&quot; value=&quot;1&quot; /&gt;
    &lt;input name=&quot;quantity_2&quot;  type=&quot;text&quot; value=&quot;1&quot; /&gt;
    &lt;input type=&quot;submit&quot; name=&quot;Add&quot; value=&quot;Add&quot; id=&quot;Add&quot; /&gt;
  &lt;/div&gt;
  </code></pre>
  <p>And a working jquery script, that transforms all these inputs to selects:</p>
  <pre><code>$('[name^=&quot;quantity_&quot;]').replaceWith('&lt;select name=&quot;quantity&quot;&gt;' +
          '&lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;' +
          '&lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;' +
          '&lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;' +
          '&lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;' +
          '&lt;option value=&quot;5&quot;&gt;5&lt;/option&gt;' +
          '&lt;/select&gt;');
  </code></pre>
  <p>But as you can see, it will replace all names attribute to &quot;quantity&quot; instead of &quot;quantity_1&quot;, &quot;quantity_2&quot; and so on (i have not two, but many of them). What i can add to this code, to make it work properly?</p>