I'm in a small deadlock, but not in my head right now. I have a list of items in which an exclude button for each item. These items are removed by passing the UUID
parameter. If I set a value to UUID
out of foreach
, it is usually deleted, but when I create the items dynamically, I can not delete the selected item.
Form hardcore:
<form id='form_delete_action' method='POST' action=''>
<tr>
<input type='hidden' name='function' value='delete_action'>
<input type='hidden' name='uuid' value='182nagojvgaf'>
<button name="delete_action" type="submit" class="btn btn-danger btn-xs">excluir</button>
</tr>
</form>
Dynamic Form: (not working)
foreach($json['actions'] as $item) {
echo "
<form role='form' id='form_delete_action' method='POST' action=''>
<tr>
<td><input type='checkbox' name='vehicle' value='car'></td>
<input type='hidden' name='function' value='delete_action'>
<input type='hidden' name='uuid' value='".$item['uuid']."'>
<td>".$item['uuid']."</td>
<td>".$item['created_at']."</td>
<td>".$item['description']."</td>
<td>".$item['category']."</td>
<td>".$item['request_at']."</td>
<td>".$item['value']."</td>
<td>
<button name='delete_action' type='submit' class='btn btn-danger btn-xs'>excluir</button>
</td>
</tr>
</form>
";
}
Maybe it's not very relative, but below is the jQuery I use for deletion:
jQuery('#form_delete_action').submit(function(){
var dados = jQuery( this ).serialize();
jQuery.ajax({
type: "POST",
url: "core/functions.php",
data: dados,
success: function( data )
{
//alert($("#description").val() + " - "+ $("#category").val() + " - "+ $("#type").val() + " - "+ $("#value").val());
location.reload();
}
});
return false;
});
Inside core/functions.php
is API calls to add, edit, and delete.
Does anyone have any idea what it can be?