1
I’m trying to use modal to delete a record from a table. By clicking on the delete button, I wanted to display a modal asking for confirmation for exclusion, so far so good, I was able to do, but go ahead that I am stuck. Follows my code.
button code of the page where the table is.
<button href="#" class="btn btn-danger btn-circle btn-sm" data-toggle="modal" data-target="#excluirmodal" onclick="Excluir(@item.idclientes)">Excluir</button>
modal code that is called.
<div class="modal fade" id="excluirmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<input id="idcliente" />
<div class="modal-body">Deseja realmente excluir?<span id="idcliente"></span></div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancelar</button>
<a class="btn btn-primary" href="../home/login/0">Sim</a>
</div>
</div>
</div>
</div>
And this is my javascript Function
function Excluir(idclientes) {
document.getElementById('idcliente').value = idclientes;
}
This is the result. The text box is for test only, to see if you are receiving table ID.
Now I am not able to delete the record when I click on "yes", I do not know how to do this function.
this command is jQuery?
– André Luiz da Silva
@Andréluizdasilva whenever see the $ symbol is Jquery
– George Wurthmann
got it, I’m using the visual studio programming on . net core, to use jquery I would have to install the jquery nuget in my project would you tell me?
– André Luiz da Silva
@Andréluizdasilva, just right click on the folder where you want to install / Add / Client-Side Library
– George Wurthmann
To use jquery I have to put between <script> jquery </script code>?
– André Luiz da Silva
Yes @Andréluizdasilva as it is also js code
– George Wurthmann
Thanks, it worked out.
– André Luiz da Silva