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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:47:07+00:00 2026-05-23T21:47:07+00:00

Am creating a simple cms and i have the following <input type=submit value=delete title=Delete

  • 0

Am creating a simple cms and i have the following

<input type="submit" value="delete" title="Delete Aricle(s)" id="delete_btn" onclick="delete_confirm()" />

<tbody>
  <?php foreach ($articles as $article): ?>
  <tr>
    <td align="center">
    <input id="article_id"name="article[]" type="checkbox" value="<?php echo $article->id; ?>" /></td>
    <td align="center"><?php echo anchor('admin/articles/edit/'.$article->id,$article->title); ?></td>
    <td align="center"><?php echo $article->author; ?></td>
    <td align="center"><?php echo $article->category; ?></td>
    <td align="center"><?php published($article->post_status); ?></td>
    <td align="center"><?php featured($article->featured); ?></td>
    <td align="center"><?php echo $article->views; ?></td>
    <td align="center"><?php echo $article->post_date; ?></td>
  </tr>
  <?php endforeach;?>
  </tbody>

The above code is wrapped in a form tag

This my javascript code

function delete_confirm() {
    var msg = confirm('Are you sure you want to delete the selected article(s)');
    if(msg == false) {
        return false;
    }
}

This is delete function in my controller

function articles_delete() {
        //Load Model
        $this->load->model("article_model");
        //Assign article id to variable
        $checkbox = $_POST['article'];
        //loop through selected checkbox
        for($i = 0; $i < count($checkbox); $i++) {
            //Call delete method of the article model
            $this->article_model->delete($checkbox[$i]);
        }
        $this->session->set_flashdata("message","Article(s) Deleted");
        redirect("admin/articles","refresh");
     }

But when cancel is clicked in the confirm dialog the form still is still submited and the selected article deleted.
Please advice on what to do

  • 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-23T21:47:09+00:00Added an answer on May 23, 2026 at 9:47 pm

    Try changing

    <input type="submit" value="delete" title="Delete Aricle(s)" id="delete_btn" onclick="delete_confirm()" />

    to

    <input type="submit" value="delete" title="Delete Aricle(s)" id="delete_btn" onclick="return delete_confirm();" />

    You’re running the delete_confirm() function inside of the onclick function. you need to return false from the onclick() function itself.

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

Sidebar

Related Questions

I'm creating a simple CMS with Rails 3. In my routes.rb file I have
I'm creating a simple CMS using kohana3 in which user can add project to
I am creating simple app on Silverlight 4. In folder of View I have
i am creating simple call filter application which restrict unwanted calls. i use following
I'm creating a simple color picker controlled by a custom slider type control. I'm
I have made a program in Flex for creating simple schedules, similar to MS
I think creating a simple user-registration on Orchard CMS should be easy? What I
I am creating very simple CMS for my organisation. My strategy is to embed
I'm creating a very simple PHP templating system for a custom CMS/news system. Each
While creating a simple client for a REST service which I have stubbed out,

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.