title: jQuery set dynamically created input fields based on difference between 2 fields
body: <p>Is there a way I can set input values of each dynamically created input fields based on a difference between 2 dynamically created fields. Below is my code and what am trying to achieve.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table id="requested-wh-stock-table" class="table table-bordered table-hover dataTable" width="100%"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Luminaire&lt;/th&gt;
              &lt;th&gt;Order Quantity&lt;/th&gt;
              &lt;th&gt;Delivered Qty&lt;/th&gt;
              &lt;th&gt;Back Order Qty&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach ($salesorder as $request)
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="text" class="form-control" name="luminaire" value="{{$request-&gt;luminaire}}" readonly&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="number" class="form-control" name="order_quantity" id="order_quantity"
                      value="{{$request-&gt;quantity}}" readonly /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="number" class="form-control" name="delivered_quantity" id="delivered_quantity" value="" /&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;input type="number" class="form-control" name="backorder_quantity" id="backorder_quantity" value=""
                      readonly /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          @endforeach
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>//Update Backorder qty based on Delivered Quantity amount
  $(document).ready(function () {
      $("#delivered_quantity").change(function () {
          var backorder_quantity = $("#order_quantity").val() - $("#delivered_quantity").val();
          $("#backorder_quantity").val(backorder_quantity);
      });
  });
  </code></pre>
  
  <p>Currently, it only updates the first field, it does not update other fields, is there a way I can loop through all fields and update Backorder field as I change the Delivered Quantity field?</p>
  
  <p><a href="https://i.stack.imgur.com/NBXA4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NBXA4.png" alt="enter image description here"></a></p>