Jquery counters & variables and square brackets
<p>A form with this hidden field is loaded</p>

<pre><code>&lt;input type = "hidden" class = "counter" value="6"&gt;
</code></pre>

<p>I use Jquery to do this</p>

<pre><code>var counter = $(".counter:last").val()
</code></pre>

<p>then a click event adds a row with this text field</p>

<pre><code>.append($('&lt;input&gt;').attr('type', 'text').attr('name', 'drugName["+counter+"]')
</code></pre>

<p>this returns</p>

<pre><code> &lt;input size="40" type="text" name="drugName["+counter+"]"&gt;
</code></pre>

<p>Where am I going wrong. I tried multiple variations.</p>

<p>Any help/references?</p>
