从控制器的view,codeigniter传递值 [英] Getting passed value in controller from view, codeigniter

查看:200
本文介绍了从控制器的view,codeigniter传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的视图,javascript和控制器编写了以下代码。

I have written the following codes for my view, javascript and controller.

每当用户点击视图中的删除按钮,它将调用名为remove_image。然后,映像名称(fullpath)将被传递到delete_banner(控制器)。

Whenever a user clicks on the delete button in the view, it will call the function named "remove_image". Then, the image name (fullpath) will be passed over to the delete_banner (controller).

fullpath的值是动态的,它可以是以下格式assets /

The value of fullpath is dynamic it can be in the following format "assets/images/banner3.jpg" and "banner4.jpg".

我面临的问题是,当全路径是assets / images / banner3.jpg时, I var_dump delete_banner控制器中的$ image_name的值,它只返回assets而不是assets / images / banner3.jpg。

Th problem I am facing is that, when the fullpath is "assets/images/banner3.jpg" and I var_dump the value of $image_name in the delete_banner controller, it only returns "assets" instead of "assets/images/banner3.jpg".

和php看起来像这样:

The link written in html and php looks something like this:

<a href="<?php echo base_url().'backendBanner/delete_banner/'.$banner['banner_path']; ?>">

视图中调用函数的代码

<td>
      <a onclick="return remove_image($(this));" rel="<?php echo $banner['banner_path']; ?>"><input type="button" class="btn btn-danger" value="Delete"></a>
</td>

函数的代码在此函数中,$ banner ['banner_path']等于fullpath



Code for the function In this function, $banner['banner_path'] is equal to fullpath

<script>
            function remove_image(img)
            {
                if(confirm('<?php echo lang('confirm_remove_image');?>'))
                {
                    var fullpath  = img.attr('rel');
                    alert(fullpath);
                    window.location="<?php echo base_url().'backendBanner/delete_banner/'; ?>" + fullpath;
                }
            }
        </script>

控制器

public function delete_banner($image_name)
    {
        var_dump($image_name);
    }


推荐答案

一个控制器从视图

这篇关于从控制器的view,codeigniter传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆