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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:51:16+00:00 2026-06-08T19:51:16+00:00

I am new to Zend Framework and jQuery. I am trying to delete a

  • 0

I am new to Zend Framework and jQuery. I am trying to delete a row from database on the basis of the returned value of confirm(). But the problem I am having is that if I press yes or no both times the selected row is deleted. I need to confirm that only when I press yes that only the selected row will be deleted. One thing I am using Zend Framework.

My codes are given below:

index.phtml

<html>
<head>
<style type="text/css" rel="stylesheet">
#simplemodal-overlay {background-color:#000;}
#simplemodal-container {background-color:#333; border:8px solid #444; padding:12px;}
#simplemodal-container a.modalCloseImg {
    background:url(x.png) no-repeat; /* adjust url as required */
    width:25px;
    height:29px;
    display:inline;
    z-index:3200;
    position:absolute;
    top:-15px;
    right:-18px;
    cursor:pointer;
}

</style> 
<script type="text/javascript" src="/jQuery.js"> </script>
<script type="text/javascript" src="/jquery.simplemodal-1.4.2.js"></script>
<script type="text/javascript">


$(document).ready(function(){
    //alert("test");
    $(".delete").click(function(e){
        //$('p').attrib('id');
        //e.preventDefault();
        //$("#deleteForm").modal();
        if(confirm("test"));

    });

    });
</script>
</head>
<center>
<?php         
echo "Student List";

?>
<p><a href="<?php echo $this->url(array('controller'=>'index', 
        'action'=>'add'));?>">Add new student</a></p>
<table border="1">
<tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Action</th>
</tr>
<?php foreach($this->students as $student) : ?>
<tr>

    <td><?php echo $student->name;?></td>
    <td><?php echo $student->email;?></td>
    <td><?php echo $student->phone;?></td>

    <td>
        <a href="<?php echo $this->url(array('controller'=>'index', 
            'action'=>'edit', 'id'=>$student->id));?>">Edit</a>
        <a class="delete" href="<?php echo $this->url(array('controller'=>'index', 
            'action'=>'delete','id'=>$student->id));?>">Delete</a>
    </td>
</tr>

<?php endforeach; ?>
</table>

</center>

</html>

IndexController.php

<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
      //  $test = new Application_Model_DbTable_Email();

    }

    public function indexAction()
    {
          $this->_helper->layout->disableLayout();
        $students = new Application_Model_DbTable_Students();
        $this->view->students = $students->fetchAll();
    }

    public function addAction()
    {
        $form = new Application_Form_Student();
        $form->submit->setLabel('Add');
        $this->view->form = $form;

        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $name = $form->getValue('name');
                $email = $form->getValue('email');
                $phone = $form->getValue('phone');
               // $image = $form->getValue('image');
                $students = new Application_Model_DbTable_Students();
                $students->addStudent($name, $email,$phone);

                $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        }

    }

    public function editAction()
    {
        $modelStudents = new Application_Model_DbTable_Students();
        $id = (int) $this->_getParam('id');

        $student = $modelStudents->fetch($id);

        $form = new Application_Form_Student($student->email);
        $form->submit->setLabel('Save');
        $this->view->form = $form;
       if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $id = (int)$form->getValue('id');
                $name = $form->getValue('name');
                $email = $form->getValue('email');
                $phone = $form->getValue('phone');
                $students = new Application_Model_DbTable_Students();
                $students->updateStudent($id, $name, $email, $phone);

                $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        } else {
            $id = $this->_getParam('id', 0);
            if ($id > 0) {

                $form->populate($modelStudents->getStudent($id));
            }
        }

    }

    public function deleteAction()
    {

                //$id = $this->getRequest()->getPost('id');
            $students = new Application_Model_DbTable_Students();
            $id = $this->_getParam('id', 0);
            $students->deleteStudent($id);
            $this->_helper->redirector('index');

    }

    //echo $test;

}

Thanks in advance,
enamul

  • 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-08T19:51:18+00:00Added an answer on June 8, 2026 at 7:51 pm

    You are using confirm incorrectly, and your posted code also has lots of doubts.
    format your links as below

     <a class="delete" id="delete_link_<?php echo $student->id?>" href="jacascript:void(0)" onclick="deleteRecord('<?php echo $this->url(array('controller'=>'index', 
                'action'=>'delete','id'=>$student->id));?>',<?php echo $student->id?>)">Delete</a>
    

    and add this function to your js

       <script>
        function deleteRecord(url,id)
        {
          if(confirm('test')){ 
          $.ajax({url:url,success:function(data){alert('Deleted Record')
                                                 $("#delete_link_"+id).hide();
                                                   }});
    
          }    
       }
        </script>
    

    EDITED :

    <script type="text/javascript">
    
    //
    $(document).ready();
    
      function deleteRecord(url)
            {
              if(confirm('test')){ 
              $.ajax({url:url,success:function(data){alert('Deleted Record')}});
              }    
           }
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty new to the zend framework and the JQuery helper. I have
I'm just new to Zend Framework. Currently what I'm trying to do is when
I feel my problem is relatively simple. I'm new to the Zend framework and
I am trying to use the new Eventmanager of the Zend Framework 2. I
I am quite a new Zend Framework user but I am not new to
I'm learning zend framework from zendCast and can't find the problem I'm using: -Zend
I'm trying to make jQuery Autocomplete, Yahoo Finance and Zend Framework work together. What
Im trying to connect from PHP(Zend Framework) code to an aspx Web Service. I
I'm trying to add a new folder to the application folder in zend framework,
I have been trying to get JQuery Sortable working on my Zend Framework application

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.