douwo1862 2018-05-24 02:44
浏览 125
已采纳

调用控制器并通过onclick监听器传递值

<?php 
    foreach($fetch_file as $row)
    {   
        echo '<tr>';
        echo '<td>' . base64_decode($row->file_perm_desc) . '</td>';
        echo '<td style = "text-align:center;">' . date_format((date_create($row->date_entry)),"M d, Y")  . '</td>';
        echo '<td class = "text-center"><a class="btn btn-info" >
        <input type = "hidden" name = "editid" class = "openid" value = ' . $row->file_perm_id . '>
        <i class="glyphicon glyphicon-folder-open"></td>';
        echo '<td class = "text-center"><a class="btn btn-warning" >
        <input type = "hidden" name = "editid" class = "unpublishid" value = ' . $row->file_perm_id . '>
        <i class="glyphicon glyphicon-comment"></td>';
        echo '<td class = "text-center"><a class="btn btn-danger" >
        <input type = "hidden" name = "editid" class = "deleteid" value = ' . $row->file_perm_id . '>
        <i class="glyphicon glyphicon-trash"></td>';
        echo '<td class = "text-center"><a class="btn btn-success" >
        <input type = "hidden" name = "editid" class = "downloadid" value = ' . $row->file_perm_id . '>
        <i class="glyphicon glyphicon-download"></td>';
        echo '</tr>';

     }      
?>  


  $('.btn-info').click(function()
    {
        var id = $(this).find('.openid').val();
        window.location.replace("<?php echo base_url();?>ClientCont/List_Files");


    });

I have this onlick listener from the value above on the user click the button it should go to the controller but I dont know how can I call controller and pass the value from id. this is in codeigniter framework hope somebody can help thanks

  • 写回答

2条回答 默认 最新

  • dtwncxs3547 2018-05-24 05:13
    关注

    Hope this will help you :

    $('.btn-info').click(function() {
      var id = $(this).find('.openid').val();
      if (id) 
      {
         window.location.href = "<?php echo base_url('ClientCont/List_Files/');?>" + id;
      }
    
    });
    

    Your controller's List_Files method should be like this :

    public function List_Files($id)
    {  
       /*echo passed id from the js here like this */
    
       echo $id;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 数据库原理及应用上机练习题
  • ¥30 征集Python提取PDF文字属性的代码
  • ¥15 如何联系真正的开发者而非公司
  • ¥15 有偿求苍穹外卖环境配置
  • ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
  • ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
  • ¥15 clousx6整点报时指令怎么写
  • ¥30 远程帮我安装软件及库文件
  • ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
  • ¥20 (求远程解决)深信服vpn-2050这台设备如何配置才能成功联网?