(function($) {
$(document).ready(function() {
$('.deleter').click(function(e) {
e.preventDefault();
$(this).closest('tr').remove(); // или $(this).parent().parent().remove();
});
});
}(jQuery));
<form class="center" name="cForm" id="test">
<table class="table table-responsive">
<thead>
<tr>
<th scope="col">Наименование</th>
<th scope="col">Количество</th>
<th>-</th>
</tr>
</thead>
<tbody id="table_ajax">
<tr>
<input type="hidden" name="form_id" value="277">
<td>Тестовый айтем 277</td>
<td><input type="number" class="form-control number" min="1" max="10" name="quantity" value="6"></td>
<td><button type="button" name="delete_item" id="item_delete" class="close deleter" aria-label="Close" value="277" data-toggle="tooltip"><span aria-hidden="true">×</span></button></td>
</tr>
<tr>
<input type="hidden" name="form_id" value="278">
<td>Тестовый айтем 278</td>
<td><input type="number" class="form-control number" min="1" max="10" name="quantity" value="6"></td>
<td><button type="button" name="delete_item" id="item_delete" class="close deleter" aria-label="Close" value="278" data-toggle="tooltip"><span aria-hidden="true">×</span></button></td>
</tr>
</tbody>
</table>
</form>
<form class="center" name="cForm" id="test">
<table class="table table-responsive">
<thead>
<tr>
<th scope="col">Наименование</th>
<th scope="col">Количество</th>
<th>-</th>
</tr>
</thead>
<tbody id="table_ajax">
<?php foreach ($post as $vars): ?>
<tr>
<td><?=htmlspecialchars($vars['item_name'], ENT_QUOTES)?></th>
<td><input type="number" class="form-control number" min="1" max="10" name="quantity" value="<?=htmlspecialchars(round($vars['qty'], 2), ENT_QUOTES)?>"></td>
<input type="hidden" name="form_id" class="id_inp" value="<?=htmlspecialchars($vars['id'], ENT_QUOTES)?>">
<td><button type="button" name="delete_item" id="item_delete" class="close deleter" aria-label="Close" data-toggle="tooltip"><span aria-hidden="true">×</span></button></td>
</tr>
<? endforeach; ?>
</tbody>
</table>
</form>
$message = '<tr>';
foreach ($user as $vars) {
$message .= '<td>' . $vars['item_name'] . '</td>
<td><input type="number" min="1" max="10" name="quantity" value="' . $vars['qty'] . '"></td>
<input type="hidden" name="form_id" value="' . $vars['id'] . '">
<td><button type="submit" name="delete_item" id="item_delete" class="close deleter" aria-label="Close" value="' . $vars['id'] . '" data-toggle="tooltip"><span aria-hidden="true">×</span></button></td>
</tr>';
}
echo $message;
$a = 'Service code 145a is used for...';
.$a = 'Service code 145a is used for...';
$b = '...you are to use code 99a.';
$pattern = '/(\d+)a/';
$res = preg_match($pattern, $str, $result);
$message = '<table>
<thead>
<tr>
<th scope="col">col1</th>
<th scope="col">col2</th>
<th scope="col">col3</th>
<th scope="col">col4</th>
</tr>
</thead>
<tbody>'
. foreach ($data as $ps): .
'<tr>
<th>' . $ps['item_1'] . '</th>
<td>' . $ps['item_2'] . '</td>
<td>' . $ps['item_3'] . '</td>
<td>' . $ps['item_3'] . '</td>
</tr>'
. endforeach; .
'</tbody>
</table>';
Спасибо! А то я пытался выбирать с помощью jquery