1

I have a function to delete table rows like this:

 $(document).on("click", ".delete", function(){
    var id = $(this).parents("tr").attr("id");
    var idutente = $(this).parents("tr").attr("id_utente");
    var nomeutente = $(this).parents("tr").attr("nomeutente");

    if(confirm('Tem certeza de que deseja excluir a requisição?'))
    {
        $.ajax({
           url: './deleteutente1',
           type: 'GET',
           data: {id: id, idutente: idutente, nomeutente: nomeutente},
           error: function() {
              alert('Algo está errado!');
           },
           success: function(data) {
                $("#"+id).remove();
                alert("Requisição removida com sucesso");  
           }
        });
    }
});                     

When the alert was displayed, I want a textarea to be displayed to the user to put the reason for removal and insert it into a database table, but I don't understand how to do that.

2
  • Avoid confirmation window , try to use modal, like bootstrap modal, you will have a full control to do whatever you want to do. Commented Nov 7, 2019 at 12:27
  • afasik there is no attribute by name id_utente & nomeutente. Use data attribute for custom properties Commented Nov 7, 2019 at 12:27

3 Answers 3

1

For a simple solution, use prompt():

const reason = prompt('Why did you remove [whatever]?');
console.log(reason);

I would advise replacing your alert with this:

const reason = prompt('Requisição removida com sucesso.\n\nWhy did you remove [whatever]?');
console.log(reason);

Sign up to request clarification or add additional context in comments.

Comments

0

You can use a prompt('message') : https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt

Comments

0
const userAnswer = prompt('Why?');

console.log(userAnswer); -> This will give you the the output to the console, however it'll be much more user friendly to create a modal instead. Take a look at the below link with the modal examples I found: https://codepen.io/timjackleus/pen/yOWpGQ , https://codepen.io/Ashbo/pen/bdvadR

Hope it helps :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.