Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

563
Views
Sweet Alert 2 Sí/No - ¿Cómo integrar una función para PHP?

Yo uso Sweet Alert 2 para buenos diálogos.

Ahora quiero usarlo para una pregunta de seguridad si una entrada de la base de datos debe eliminarse o no. No hay problema para mostrar el cuadro de diálogo, pero no puedo encontrar una manera de integrar una función si se confirma la eliminación. ¿Podría alguien ayudarme por favor?

Ese es el código por ahora:

 <script> Swal.fire({ title: '', text: "Diesen Eintrag wirklich löschen?", icon: 'warning', showCancelButton: true, confirmButtonText: 'Ja', cancelButtonText: 'Nein', reverseButtons: true }).then((result) => { if (result.isConfirmed) { Swal.fire( '<Here a function if delete is confirmed>' ) } else { Swal.fire( '<Here a function to go back>' ) } }) </script> <?php public function deleteConfimred(){ // Delete the entry }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede enviar un formulario usando JS que se envía al archivo PHP donde está su función.

HTML:

 <form id="yourFormId" action="yourphpfile.php" method="post"> <input type="hidden" name="delete" value=""> </form> <button type="button" onclick="confirmDelete()">Delete</button> <script> function confirmDelete() { Swal.fire({ title: '', text: "Diesen Eintrag wirklich löschen?", icon: 'warning', showCancelButton: true, confirmButtonText: 'Ja', cancelButtonText: 'Nein', reverseButtons: true }).then((result) => { if (result.isConfirmed) { document.getElementById("yourFormId").submit(); } }) } </script>

suarchivophp.php:

 <?php if(isset($_POST['delete'])) { deleteConfirmed(); } public function deleteConfirmed(){ // Delete the entry } ?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!