我想乘以service_cost * service_days的值,但service_cost和service_days是動態的,可能會重複多次。之後,我想計算所有乘法結果的總和並將其分配給小計文本框。如何從動態文本框乘以和計算值?
<div class="form-group">
<label for="place" class="col-sm-2 control-label">Services</label>
<div class="col-md-10" id="check" style="padding-left: 0px !important;">
<?php
$sql = "SELECT * FROM service_ipd ORDER BY service_id ASC";
$q = $pdo->query($sql);
while($row = $q->fetch(PDO::FETCH_ASSOC))
{
?>
<div class="col-sm-5" style="margin-bottom:10px;">
<div class="input-group date">
<div class="input-group-addon">
<input type="checkbox" value="<?php echo $row['service_id']; ?>" name="service[]" id="service">
</div>
<input type="place" class="form-control" name="" id="" placeholder="" value="<?php echo $row['service_name']; ?>" disabled="true">
</div>
</div>
<div class="col-sm-2">
<div class="input-group">
<input type="text" class="form-control" name="service_cost[]" id="service_cost" value="<?php echo $row['service_cost']; ?>" placeholder="" readonly>
</div>
</div>
<div class="col-sm-2">
<div class="input-group">
<input type="text" class="form-control" name="service_days[]" id="service_days" placeholder="">
</div>
</div>
<div class="clearfix"></div>
<?php } ?>
</div>
</div>
<input type="name" class="form-control" name="invoice_generation_date" id="sub_total" placeholder="Sub Total">
什麼是最佳解決方案?請幫忙。
要計算在PHP或JavaScript值是多少? –
@LoïcFaure-Lacroix:在javascript中,我想要顯示它的運行時 – swap