title: How to delete using javascript in codeigniter?
body: <p>Need a little help in here. I just want to delete a row from database using javascript. But facing some problems.</p>
  
  <p>Here is my view:</p>
  
  <pre><code>&lt;?php echo anchor("#","Delete",array('class'=&gt;'selectedpagination', 'onclick'=&gt;'confirmDelete("admin/editpage/","'.$file-&gt;page_id.'");'))?&gt;
  </code></pre>
  
  <p>And Javascript is here</p>
  
  <pre><code>function confirmDelete(controller,id)
  {
      if(confirm("Are you sure you want to delete this record"))
      {
          &lt;!--location.href="main.php?page="+page+"&amp;tblname="+tblname+"&amp;fldname="+fldname+"&amp;id="+id+"&amp;action=delete";--&gt;
          window.redirect("http://localhost/sama/index.php/admin/"+controller+"/"+id);
      }
  </code></pre>
  
  <p>How to make it work?? Its not working.</p>
  
  <p>Please anyone or someone, desperately needing help. Thanks in advance.</p>