title: How to make autofill input text from a select dropdown box with multiple lines?
body: <p>I am trying to have a function where a user can select items they want from a drop-down box, then the price will be displayed in an input box at its side.</p>
  
  <p>I am now facing problem to have the same function in multiple lines. Code are as below:</p>
  
  <pre><code>&lt;td class="formiterate" &gt;                                               
      &lt;select id="Employee_ID" name="id[]"&gt;
          &lt;option value=""&gt;Select one&lt;/option&gt;
          &lt;?php
          $st = $pdo-&gt;prepare("SELECT * FROM tbl_stock");
          $st-&gt;execute();
          $rowes = $st-&gt;fetchAll(PDO::FETCH_ASSOC);
          foreach ($rowes as $rowe) {
              ?&gt;&lt;option value="&lt;?= $rowe ['id']; ?&gt;"&gt;&lt;?= $rowe ['stock_item']; ?&gt; (&lt;?= $rowe ['stock_brand']; ?&gt;)&lt;/option&gt;&lt;?php
          }
      ?&gt;
      &lt;/select&gt;
  &lt;/td&gt;
  &lt;td class="formiterate"&gt;&lt;input type="text" name="Last_name[]" id="Last_name"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>As you can see, when you select from the <code>Employee_ID</code>, the item price will reflect in the <code>Last_name[]</code> input box.</p>
  
  <p>Whilst the code works fine for a single row, I am not able to iterate the function for multiple row.</p>
  
  <p>Below is my javascript:</p>
  
  <pre><code>$(function() { // This code will be executed when DOM is ready
      $('#Employee_ID').change(function() { // When the value for the Employee_ID element change, this will be triggered
          var $row = $(this); // We create an jQuery object with the select inside
          $.post("getData.php", { Employee_ID : $row.val()}, function(json) {
              if (json &amp;&amp; json.status) {
                  $('#Last_name').val(json.lastname);
              }
          })
      });
  })
  </code></pre>
  
  <p>I have tried adding <code>.closest(".rows")</code> at <code>var ($row)= $this</code>, but noting happened.</p>
  
  <p>Please help.</p>
  
  <p>Thanks</p>