duangan6636 2016-03-03 12:50
浏览 20

按钮时如何导航,复选框响应

My code igniter web page has side bar check boxes and news articles on main panel updated from database. when i select check box i want to pass check box ID to controller and return only relevant news articles according to check box value. How to do it? What is the mechanism using here? example web site same as i expected

 <?php 
    foreach ($data as $add) {
        echo "<div>";
        echo '<p class="target">' .$add->news_data.  '</p>';
        echo "</div>";
    }
    ?>
  • 写回答

2条回答 默认 最新

  • duanfangfei5558 2016-03-03 13:42
    关注

    To Do that ...You have to make an ajax call "onclick" of checkbox group and then on ajax call you have to fire query with the IDs which have been passed

    So,set AJAX function

    $("#sidebar input[type='checkbox']").click(function(e){
    
               var values = [];    
               $( "input[name='post_type']:checked" ).each(function(){
               values.push($(this).val());
               });
              var Type = values.join(", ");
    
                $.ajax({
                    type: "POST",
                    url: "filterpost.php",
                    data: "typID="+Type ,
                    cache: false,
                    success: function(){ 
                        alert("success");//just to check only 
                    }
                });
         });
    

    Step 2:Now create filterpost.php file

    Now get the post value at the other side $id = $_POST['typID']; and from here fire the appropriate query using "IN" keyword

    Step 3: and pass that data to the view after that.

    I can't give you the whole example directly...just follow this steps I hope you will get solution

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100