title: PHP concatenation $i in jQuery
body: <p>Bit of a strange one, I have a webpage that iterates through a set number of times using <code>while ($i &lt;= 21):</code>. During this iteration I have a dropdown in each which displays some values I pulled from a database, at this point that specific value doesn't matter but the id of each dropdown uses the value of <code>$i</code>. For example:</p>
  
  <pre><code>&lt;select name="dropdown&lt;?php echo $i; ?&gt;" id="dropdown&lt;?php echo $i; ?&gt;"&gt;
    &lt;option value="1"&gt;One&lt;/option&gt;
    &lt;option value="2"&gt;Two&lt;/option&gt;
    &lt;option value="3"&gt;Three&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>What I am then wanting to do is take the value selected from that dropdown and place in another field that also has the id corresponding to the iteration number, for example:</p>
  
  <pre><code>&lt;textarea name="textfield&lt;?php echo $i; ?&gt;" id="textfield&lt;?php echo $i; ?&gt;"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>I am using the following code for the jQuery to get the value from the dropdown and put it into the textarea:</p>
  
  <pre><code>&lt;script&gt;
    $("#dropdown&lt;?php echo $i ?&gt;").on("change",function(){
        //Getting Value
        var selValue = $("#dropdown&lt;?php echo $i ?&gt;").val();
        //Setting Value
        $("#textfield&lt;?php echo $i ?&gt;").val(selValue);
    });  
  &lt;/script&gt;
  </code></pre>
  
  <p>However it doesnt seem to like the use of <code>&lt;?php echo $i ?&gt;</code> part as if i replace that with for example 2 or 3 then it works for that iteration.</p>
  
  <p>I have tried setting the variable in PHP like: <code>$textfield= 'textfield'.$i;</code> and the using this as a whole in jQuery like this: <code>$("#&lt;?php echo $textfield ?&gt;").val(selValue);</code> but it doesnt like that either. Interstining if I change it to <code>$textfield= 'textfield'.'2';</code> or <code>$textfield= 'textfield2';</code> it works. Seems like it doesnt like my use of <code>$i</code>, is it the PHP concatenation that it doesnt like?</p>
  
  <p>Anyone experienced this or know of a fix?</p>