Morning, I have form with dynamically rows and select option into first column. I would like to set a value into specific element of my row after event select. Actually for each row, all elements change after select.
My form:
<tbody>
<tr>
<td>
<Select class="form-control form-control-sm" name="item_desc[]" id="item_desc" type="integer" onchange="select_field(this)">
<option> </option>
@foreach ($articles as $article)
<option>{{$article->id}}</option>
@endforeach
</Select>
</td>
<td class="writefields" name="item_fields[]"></td>
<td class="writenature"></td>
<td class="writeuom"></td>
<td><input class="form-control form-control-sm" type="integer" name="item_quantity[]"></td>
<td><i class="btn far fa-trash-alt" onclick="remove_row(this)"></i></td>
</tr>
</tbody>
My JQuery Code :
function select_field(e)
{
...,
$.ajax({
type: "POST",
url: "/achats/selection",
data: {_token: CSRF_TOKEN, code_item : selection },
dataType: "JSON",
success: function (data) {
$('.writefields').text(data.UoM);
$('.writeuom').text(data.UoM);
$('.writenature').text(data.NatureAChat);
}
});
}
Thks for your helps !