当点击复选框时,会弹出另一个模态以显示所选值的数量,然后检查Geda Jumuad并添加“2”作为数量值,然后将值'2'放在checbox的开头。 。 我想将数量值放在所选复选框旁边..请帮帮我。 继承我的代码
ClientScriptManager cs = pageInstance.ClientScript;
和javascript。 。
<b>Menu: </b>
<br>
<div class="menucontainers" style="background: #fff; border-style: solid; border-width: 2px; border-color:#ccccff; width: 400px; height:150px; overflow:auto;">
<!-- <img src ="../1.jpg" class="img-rounded"> -->
<ul>
<?php
include ('myConnection.php');
$query = "Select * from menu_category order by menu_cat_name";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$menucatname = $row['menu_cat_name'];
$menucatid = $row['menu_cat_id_inc'];
?>
<li class="dropdownz" style="border-style: solid;border-color: white; border-bottom: 2px; border-left: 2px; border-right: 2px">
<a href="#" data-toggle="dropdownz" style="font-size:15px"> <i id = "arrow" class="icon-arrow"></i><?php echo "$menucatname"; ?></a>
<ul id="ddownz-menu" class="dropdownz-menu">
<li>
<?php
$query2 = "Select * from menu where menu_cat_id_inc = '$menucatid' order by menu_name";
$result2 = mysql_query($query2);
$countme = 0;
while ($row2 = mysql_fetch_array($result2)) {
$menuname = $row2['menu_name'];
$price = $row2['price'];
if ($countme % 2 == 0)
{
?>
<div class="col col-md-6">
<input type="checkbox" id="newmenu" name="cbox[]" style="font-size:15px" value="<?php echo $row2['menu_id_inc'];?>">
<?php
echo '<span id = "quantity" style = "color:black;"></span>'. " " . "$menuname";
?>
</div>
<?php
}
else
{
?>
<div class="col col-md-4">
<input type="checkbox" id="newmenu" name="cbox[]" value="<?php echo $row2['menu_id_inc'];?>">
<?php
echo '<span id = "quantity" style = "color:black;"></span>'. " " . "$menuname";
?>
</div>
<?php
}
}
?>
</li>
</ul>
</li>
<?php
}
?>
</ul>
</div>
`
答案 0 :(得分:0)
我可能会误解你的问题,但是......我认为你的错误顺序是错误的。将跨度放在$ menuname之后。
而不是
echo '<span id = "quantity" style = "color:black;"></span>'. " " . "$menuname";
待办事项
echo "$menuname".' <span id = "quantity" style = "color:black;"></span>';
您还必须为跨度分配唯一的ID。虽然您的复选框是动态的,但您可以检索这些复选框的值并将其附加到“数量”。您将生成ids'quantity1','quantity2','quantity3'。将上一行代码更改为
echo "$menuname".' <span id = "quantity'.$row2['menu_id_inc'].'" style = "color:black;"></span>';
你还需要在你的javascript中做类似的事情。在javascript变量中检索复选框值编号,并将其附加到“数量”这里
document.getElementById('quantity' + value).innerHTML = qty;