我一直在尝试自动计算所选单选按钮的总和。单选按钮的值来自数据库。这是我到目前为止所尝试过的。它仅适用于第一个模式。这是手动刺激数据的片段的链接。
https://jsfiddle.net/k5zh9m4d/1/
<section class="py-5">
<div class="container">
<h1 class="display-4">Menu</h1>
<?php
include "config/dbconfig.php";
$data['productCode'] = "0"; // sample data
$stmt = $conn->prepare("SELECT * FROM tbl_products");
//$stmt->bind_param("i", $data['productCode']);
$stmt->execute();
foreach ($stmt->get_result() as $i => $stuff) { ?>
<div class="row">
<div class="col-6">
<img src="<?php echo $stuff['image']; ?>" class="img-fluid" alt="Sample milk tea">
</div>
<div class="col">
<h3><?php echo $stuff['itemname']; ?></h3>
<p><?php echo $stuff['itemdescription']; ?></p>
<hr>
<h4>
<button type="button" class="btn btn-secondary btn-lg" disabled>
<i class="fa fa-glass fa-lg" aria-hidden="true"></i>
<?php echo $stuff['itempricethree']; ?>
</button>
</h4>
<br>
<hr>
<button type="button" class="btn btn-outline-danger btn-lg" data-toggle="modal" data-target="#<?php echo $stuff['itemcode']; ?>">
<i class="fa fa-cart-plus" aria-hidden="true"></i>
Order
</button>
</div>
</div>
<br><br>
慕田峪9158850
翻翻过去那场雪