doulei6330 2013-02-21 16:56
浏览 43

将参数传递给colorbox

I am using a colorbox.

<a class="publishpost" href="<?= base_url()."publish_ads/publishon/".$adds[$i]->getId()?>"></a>
                        <script>
                                $(document).ready(function(){ 
                                    $('.publishpost').colorbox({ width: '900px', height: '500px' });
                                });
                        </script>

I have this link that points to a codeigniter controller. I would like to access some variable from the view in which I load the colorbox. How can I do this. I thought about a form or maybe something with jquery but I still dont know how pass the parametres.

The values that I intend to pass as parametres are something like this for example:

<div class="external_wall_right_col_sub_ad_img"><img src="<?=$img?>" alt="small ad"></div>

I want to pass the $img variable to the colorbox.

  • 写回答

2条回答 默认 最新

  • doulie0178 2013-02-21 17:47
    关注

    Determining how you want the front-end to work is up to you--passing the data, however, I can help you with.

    If you choose to use a form, you can access the form data in your controller that you are submitting to. From there you can define the $img variable as such:

    $data['img'] = $this->input->post('input_name');
    

    Then when you load your view, pass the data:

    $this->load->view('view_name', $data);
    

    This will pass all variables declared inside $data to your view. You can now access that variable in your view as you would like:

    <img src="<?php echo $img; ?>" alt="small ad">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘