HI all,
I have some html which accommodates many rows of the same type of data ie product name, id, price, quantity:
<tbody id="tableQuotation">
<tr class="quotation delete_row ">
<td>{{ Form::text('product_name[]',' ',['class'=>'form-control product_name','placeholder'=>'Min. 3 characters']) }}</td>
<td> {{ Form::text('product_id[]',' ', ['class'=>'product_id form-control','readonly'=>'readonly' ]) }}</td>
<td>{{ Form::text('price[]',' ',['class'=>'form-control price','readonly'=>'readonly', ]) }}</td>
<td>{{ Form::text('quantity[]',' ', ['class'=>'form-control quantity ']) }}</td>
<td>{{ Form::text('cost[]',null ,['class'=>'form-control cost', 'readonly'=>'readonly' ]) }}</td>
<td style="text-align: center">{{ Form::checkbox('delete','true') }}</td>
</tr>
</tbody>
The above HTML is repeated for every row ( ie every product) on the page.
The very last td contains a checkbox which when clicked fires a function to remove the closest row ie closest product.
Here is my problem: I want to select the product_id contained within the second td. I have tried everything I can think of with no luck. First I will show you the code which selects the row in general and removes the row. This works:
$("#tableQuotation,#editTableQuotation").on('click', 'td input:checkbox', function () {
$(this).closest("tr.delete_row").remove();
Here is the code I have tried every which way, and it DOES NOT work. all I get is id undefined
$("#tableQuotation,#editTableQuotation").on('click', 'td input:checkbox', function () {
var id = $("tr.delete_row.product_iddone").closest().val();
So any ideas who I can grab the product_id out of the td ??
Many thanks !!