0
I have a program here that controls a to-do list that is saved and read through the database (SQL). The main page contains a table and in each row a delete button for each table entry... I don’t know much about Ajax but I wanted to use a modal to confirm the exclusion (form sends 2 variables to another page that performs the operations of the bank: the first is the id of the entry that will be excluded; and the other would be the type of operation, in the case, exclusion).
If anyone can shed some light on how to do that.
Modal that is called when I click on "delete button":
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="modalLabel">Excluir Item</h4>
</div>
<div class="modal-body">Deseja realmente excluir este item? </div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-ok">Sim</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Não</button>
</div>
</div>
</div>
</div>
Button "delete record":
<td class="actions">
<button type='submit' class='btn btn-danger btn-xs' id='deleta' alt='Excluir' data-toggle="modal" data-target="#delete-modal"
name='opbanco' value='excluir' title="Excluir"><span class="glyphicon glyphicon-trash" ></span></button>
</td>
The input
is inside a form sending the data (codigo(id)
and opbanco(operacao a ser realizada)
).
Edit:
I tried as @Guilhermenascimento suggested "var data = 'id=' + id + '&operation=opbanco';" and it does not roll, I believe I was not clear in my doubt, I will complement the code
" name='cod_prdc'>
This is the field of the form that stores the line id, and by clicking on the delete button it sends to another page (database.php) the 2 parameters through the reference name of the fields the other parameter 'opbanco' is on the delete button
This helps https://answall.com/a/159788/3635 ?
– Guilherme Nascimento
So dude I saw this article, but in this case it sends only the id by POST to the other page, I wanted to know a way to send the 2 parameters at once by confirming the deletion (the id and the type of operation(that would be the name="opbanco" of the boot delete))
– Yago Santos
Yago just adjust it:
var data = 'id=' + id ;
for something similar to thisvar data = 'id=' + id + '&operacao=opbanco';
– Guilherme Nascimento
This post indicated by @Guilhermenascimento has the solution to your problem, just add the delete operation.
– Laércio Lopes
I edited again the file, I still can’t get guys...generating the direct modal by html it even appears but the event that should occur when I click on "Yes" does not happen in...but without the statement ajax
– Yago Santos