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 7091329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:10:18+00:00 2026-05-28T08:10:18+00:00

I have an HTML table of rows tied to database rows. I’d like to

  • 0

I have an HTML table of rows tied to database rows. I’d like to have a “delete row” link for each row, but I would like to confirm with the user beforehand.

Is there any way to do this using the Twitter Bootstrap modal dialog?

  • 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-05-28T08:10:18+00:00Added an answer on May 28, 2026 at 8:10 am

    GET recipe

    For this task you can use already available plugins and bootstrap extensions. Or you can make your own confirmation popup with just 3 lines of code. Check it out.

    Say we have this links (note data-href instead of href) or buttons that we want to have delete confirmation for:

    <a href="#" data-href="delete.php?id=23" data-toggle="modal" data-target="#confirm-delete">Delete record #23</a>
    
    <button class="btn btn-default" data-href="/delete.php?id=54" data-toggle="modal" data-target="#confirm-delete">
        Delete record #54
    </button>
    

    Here #confirm-delete points to a modal popup div in your HTML. It should have an “OK” button configured like this:

    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    ...
                </div>
                <div class="modal-body">
                    ...
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-danger btn-ok">Delete</a>
                </div>
            </div>
        </div>
    </div>
    

    Now you only need this little javascript to make a delete action confirmable:

    $('#confirm-delete').on('show.bs.modal', function(e) {
        $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
    });
    

    So on show.bs.modal event delete button href is set to URL with corresponding record id.

    Demo: http://plnkr.co/edit/NePR0BQf3VmKtuMmhVR7?p=preview


    POST recipe

    I realize that in some cases there might be needed to perform POST or DELETE request rather then GET. It it still pretty simple without too much code. Take a look at the demo below with this approach:

    // Bind click to OK button within popup
    $('#confirm-delete').on('click', '.btn-ok', function(e) {
    
      var $modalDiv = $(e.delegateTarget);
      var id = $(this).data('recordId');
    
      $modalDiv.addClass('loading');
      $.post('/api/record/' + id).then(function() {
         $modalDiv.modal('hide').removeClass('loading');
      });
    });
    
    // Bind to modal opening to set necessary data properties to be used to make request
    $('#confirm-delete').on('show.bs.modal', function(e) {
      var data = $(e.relatedTarget).data();
      $('.title', this).text(data.recordTitle);
      $('.btn-ok', this).data('recordId', data.recordId);
    });
    
    // Bind click to OK button within popup
    $('#confirm-delete').on('click', '.btn-ok', function(e) {
    
      var $modalDiv = $(e.delegateTarget);
      var id = $(this).data('recordId');
    
      $modalDiv.addClass('loading');
      setTimeout(function() {
        $modalDiv.modal('hide').removeClass('loading');
      }, 1000);
    
      // In reality would be something like this
      // $modalDiv.addClass('loading');
      // $.post('/api/record/' + id).then(function() {
      //   $modalDiv.modal('hide').removeClass('loading');
      // });
    });
    
    // Bind to modal opening to set necessary data properties to be used to make request
    $('#confirm-delete').on('show.bs.modal', function(e) {
      var data = $(e.relatedTarget).data();
      $('.title', this).text(data.recordTitle);
      $('.btn-ok', this).data('recordId', data.recordId);
    });
    .modal.loading .modal-content:before {
      content: 'Loading...';
      text-align: center;
      line-height: 155px;
      font-size: 20px;
      background: rgba(0, 0, 0, .8);
      position: absolute;
      top: 55px;
      bottom: 0;
      left: 0;
      right: 0;
      color: #EEE;
      z-index: 1000;
    }
    <script data-require="jquery@*" data-semver="2.0.3" src="//code.jquery.com/jquery-2.0.3.min.js"></script>
    <script data-require="bootstrap@*" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    <link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
    
    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
          </div>
          <div class="modal-body">
            <p>You are about to delete <b><i class="title"></i></b> record, this procedure is irreversible.</p>
            <p>Do you want to proceed?</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            <button type="button" class="btn btn-danger btn-ok">Delete</button>
          </div>
        </div>
      </div>
    </div>
    <a href="#" data-record-id="23" data-record-title="The first one" data-toggle="modal" data-target="#confirm-delete">
            Delete "The first one", #23
        </a>
    <br />
    <button class="btn btn-default" data-record-id="54" data-record-title="Something cool" data-toggle="modal" data-target="#confirm-delete">
      Delete "Something cool", #54
    </button>

    Demo: http://plnkr.co/edit/V4GUuSueuuxiGr4L9LmG?p=preview


    Bootstrap 2.3

    Here is an original version of the code I made when I was answering this question for Bootstrap 2.3 modal.

    $('#modal').on('show', function() {
        var id = $(this).data('id'),
            removeBtn = $(this).find('.danger');
        removeBtn.attr('href', removeBtn.attr('href').replace(/(&|\?)ref=\d*/, '$1ref=' + id));
    });
    

    Demo: http://jsfiddle.net/MjmVr/1595/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML table with various rows, each has a delete button with
I have html table with 3 rows each row contains two <td> one with
how remove html table rows after 2nd row? if in table have 5 row,
I have an HTML table having n rows and each rows contain one radiobutton
I have a HTML table where some rows have a button like this: <td
I have an HTML table with rows (20 rows). Every row has a listbox
I have an HTML table with several rows. If you hover on the row
i have a simple html table where i want to delete and add rows
I have an HTML table, to which I would like to add or remove
I have an html table with many rows. I'm currently grouping several rows inside

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.