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

237
Views
Cancel button for pop up message before delete not functioning

I've facing problem where, when the confirmation message appear, I click the cancel button, the data will be also deleted. Can someone suggest where need to be fix? Below is the code.

echo "<a onClick='myFunction()' href='./delete.php?userID=".$row['userID'] ."'><button>Delete</button></a>";

    <script> 
        function myFunction() {
            $r = confirm("OK to delete?");
            if ($r == false) {
                return false;
                } 
        }
    </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The anchor tag event has to be prevented when the 'Cancel' is clicked with event.preventDefault().

Example

<a onClick="myFunction()" href="https://google.com">Delete
<script>
   function myFunction() { 
      let r = confirm("OK to delete?"); 
      
      if (r == false) { 
        // It will prevent visit to 'https://google.com'
        return event.preventDefault();
      } 
   }
    
</script>

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!