delete provides confirmation, but also needs error message popping when cant del

function deleteRow(id)
{
    var answer= confirm('Do you really want to delete?');
      if(!answer){
        event.preventDefault();
      }
      else {
        var current =  $('#current').val();
        var dataString = {index:current,action:'delete',id:id};
        updateList(dataString);
   }
}
the above is present in the view form 

the below code is in the controller 
[php]
 public function listinandoutAction()
    {
        $index = 0;
        $this->_helper->layout->disableLayout();
        if($this->_request->has('index'))
            $index = $this->_request->getPost('index');
        $pay_period = $this->view->GetPayPeriod($index);
        if($this->_request->has('action') &&  $this->_request->getPost('action')=='delete') {
            $id = $this->_request->getPost('id');
            if($this->_timesheet->deleteTimeInandout($id))
            {
            $log_id = $this->_log('inandout',"Time In/Out entry deleted; ID:".$id);
              } else {
            $log_id = $this->_log('inandout',"Time In/Out delete failed as the remaining Time In/Out hours is less than the timesheet hours ID:".$id);
           }
        }
[/php]

when delete is clicked a confirmation box arrives and as per my function it will delete if the function is correct and if not it will not delete

when it does not delete i want a warning message to pop up when i am clicking on delete. could you please let me know what modification i have to make. i am trying since two days. Any help would be really appreciated





Sponsor our Newsletter | Privacy Policy | Terms of Service