Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:11:04+00:00 2026-06-12T17:11:04+00:00

I have implemented the functionality to remove users from the database in my application.

  • 0

I have implemented the functionality to remove users from the database in my application. A user chooses user(s) (checkboxes) and clicks submit. A confirmation box is shown asking the user if he wants to delete username. Everything works except that if Cancel is clicked the user(s) still gets removed.

Why is that and how could I prevent it (I have check and return false runs)

from usercontroller.php:

if ($userView->TriedToRemoveUser()) {
  $userIds = $userView->GetUsersToRemove();

  if ($userIds != 0) {
    $removeTry = $userHandler->RemoveUser($userIds);

    if ($removeTry) {
      $xhtml = \View\UserView::USER_REMOVED;
    }
    else {
      $xhtml = \View\UserView::FAILED_TO_REMOVE_USER;
    }
  }
}

from userview.php:

public function TriedToRemoveUser() {
  if (isset($_POST[$this->_submitRemove])) {
    return true;        
      }
      else {
        return false;
      }
}

from the js.file:

$('#form3').submit(function() {
  $('input[type=checkbox]').each(function () {
    if( this.checked ) {
      var username = $(this).attr('user');

      var confirmBox = confirm('Do you really want to remove the user ' + username + ' ?');

      if (!confirmBox) {
        return false;
      }
      }
  });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:11:05+00:00Added an answer on June 12, 2026 at 5:11 pm

    (WARNING: All code is off the top of my head and not properly tested)

    Assuming you are talking about the return false; statement in the javascript:

    The return false; will not prevent the submit method as it is only breaking from the .each() method. All this will do is stop the iteration over the checkboxes.

    Try something like:

    $('#form3').submit(function () {
        var doDelete = true;
    
        $('input[type=checkbox]').each(function () {
           // ...
    
           if (!confirmBox) {
               doDelete = false;
               return false; // Deletion has been cancelled so there is no need to continue the iteration
           }
        });
    
        if (!doDelete) {
            return false;
        }
    });
    

    This will prevent the entire form from being submitted if the user cancels any of the selected users. If you’re intention is to continue to submit any confirmed users you could try something like the following:

    $('#form3').submit(function () {
        $('input[type=checkbox]').each(function () {
           // ...
    
           if (!confirmBox) {
               $(this).attr('checked', false); //Uncheck this box so that it isn't submitted
           }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented Add to Favourites functionality for my iPhone application. It works fine
I have implemented the .NET Login functionality, and I am receiving a JavaScript Error
I have a form with most of its functionality implemented using standard TAction. I
I have made an android app which working fine. I implemented the Login functionality
I have implemented a table view with multiple threads. Currently when a user taps
I have implemented comments functionality in one of my sites using CakePHP and it's
I have implemented remember me functionality as this question How to create "remember me
I am working on a web site with login registration functionality.I have implemented the
I have a rails application in which I implemented some feature. Now I want
I have implemented AJAX functionality on my Wordpress site and all my menu items

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.