单击新选项卡时显示选中的文本无效

时间:2016-10-13 11:52:45

标签: php jquery ajax activerecord checkbox

我试图在一个div中实现显示检查值文本。

enter image description here

默认情况下,Tiffen处于活动状态,因此当我点击空闲和puri图像时,该图像的文本即将到来并显示在所选食物列表中

但是当我点击左侧菜单中的午餐时,如图所示;他们有一些食物,如:豆腐和鱼,当我检查它们的文字没有出现,但当我去tiffen标签并做任何检查修改时,午餐价值随着tiffen而来

这些是我的代码:

这是我的部分代码:

<section>
<div class="products">
<div class="container">
<div class="col-md-3 rsidebar">
<div class="related-row">
    <h4 class="text-center">Food Menu</h4> 
    <ul class="nav nav-pills nav-justified">
        <li role="presentation" class="active"><a href="#tiffin" aria-controls="home" role="tab" data-toggle="tab"> Tiffin </a></li>
        <li role="presentation"><a href="#lunch" aria-controls="home" role="tab" data-toggle="tab"> <i></i> Lunch </a></li>
        <li role="presentation"><a href="#dinner" aria-controls="home" role="tab" data-toggle="tab"> Dinner </a></li>
    </ul>       
</div>
<div class="related-row" id="FoodSelected">
    <h4 class="text-center">Food Selected</h4> 
    <ul class="nav nav-pills nav-justified">
        <li class="active"><a id="selectedfood"></a></li>
    </ul>    
</div>
</div>
<form id="FoodForm">
<div class="tab-pane active" id="tiffin">
    <div class="products-row">
        <?php $tq=$conn->query("select * from os_dish where dish_status=1 and dish_type=1 order by id_dish ASC");
            while ($tiffen = $tq->fetch_assoc()) {
            ?>  
            <div class="col-md-3"> 
                <div class="foodmenuform row text-center">
                    <input type="checkbox" id="<?php echo $tiffen['dish_name'];?>" class="Foodmenu" value="<?php echo $tiffen['dish_name'];?>" name="tifeen[]" hidden>
                    <label for="<?php echo $tiffen['dish_name'];?>"><img src="img/dish/<?php echo $tiffen['dish_image']; ?>" class="img img-responsive" /></label>
                    <h3><?php echo $tiffen['dish_name'];?></h3>
                </div>
            </div>
        <?php }  ?>
    </div>
</div>    
<div class="tab-pane" id="lunch">
    <div class="products-row">
        <?php $lq=$conn->query("select * from os_dish where dish_status=1 and dish_type=2 order by id_dish ASC");
            while ($lunch = $lq->fetch_assoc()) {
            ?>  
            <div class="col-md-3"> 
                <div class="foodmenuform row text-center">
                    <input type="checkbox"  id="<?php echo $lunch['dish_name'];?>" class="FoodMenu" value="<?php  echo $lunch['dish_name'];?>" name="lunch[]" hidden>
                    <label for="<?php echo $lunch['dish_name'];?>"><img src="img/dish/<?php echo $lunch['dish_image']; ?>" class="img img-responsive" /></label>
                    <h3><?php echo $lunch['dish_name'];?></h3>
                </div>
            </div>
        <?php }  ?>
    </div>
</div>
<button id="FoodSubmit" class="btn btn-primary btn-lg btn-block">Submit Food Menu</button>
</form>
</section>

这是我的脚本代码:

<script type="text/javascript" language="JavaScript">
$(".Foodmenu").click(function(){
var checkedFood = $('input[type=checkbox]:checked').map(function(){
    console.log($('input[type=checkbox]:checked').serialize());
    return $(this).attr('value');
}).get().join("<br>");
$("#selectedfood").html(checkedFood);
});
</script>

1 个答案:

答案 0 :(得分:0)

我得到了所有代码都写的解决方案但是错误是在类名问题我给了小FoodMenu istead Foodmenu