How to ask the reason for an exclusion using confirm and prompt?

2

I have a project ready and I need to make a change. When I am going to delete a record named print "javascript:if(confirm('" . $msg . "'))"; however I have to ask the reason for the exclusion. I would like to ask this reason with a prompt.

The user will click the button, and a prompt will appear asking the reason for the deletion. If I fill in and click ok, I get this value and I'm going to go with href :

<a href=" <?php msg("Deseja desvincular associado?") ?>
          {location='?pagina=alu&acao=excluir&
          cd_aluno=<?php echo $oquefazer->registros->cd_aluno; ?>';}">
          <button class="btn"><p class="icon-remove-sign"></p></button>
</a>
    
asked by anonymous 10.12.2015 / 12:41

1 answer

1

You can use the javascript prompt

console.log(mostrarPrompt());

function mostrarPrompt() {
  var motivo = prompt('Informe o motivo');
  if (motivo === '')
    mostrarPrompt();
  if (motivo !== null)
    return motivo;
  return null;
}
    
10.12.2015 / 12:55