我想檢索表中的數據,然后將其制成圖表請幫助如何從整體上檢索總ID中的數據</table> <label for="">Table Hasil</label> <table class="table" border="1" id="hasil"> <thead class="thead-dark"> <tr> <th>No</th> <th>Alternatif</th> <th>C1</th> <th>C2</th> <th>C3</th> <th>C4</th> <th>Total</th> </tr> </thead> <?php $i=1; foreach ($saw as $s) { ?> <tr> <td> <?= $i++ ?> </td> <td> <?= $s->alternatif ?> </td> <td> <?= $a = round($s->c1/$nilaiMax->c1 *0.25,2) ?> </td> <td> <?= $b = round($s->c2/$nilaiMax->c2 *0.25,2 ) ?> </td> <td> <?= $c = round($s->c3/$nilaiMax->c3*0.3,2) ?> </td> <td> <?= $d = round($s->c4/$nilaiMax->c4*0.2,2) ?> </td> <td id="total"> <?= $total = $a+$b+$c+$d ?> </td> </tr> <?php } ?></table>感謝您的幫助
2 回答

UYOU
TA貢獻1878條經驗 獲得超4個贊
代替ID
<td id="total">
<?= $total = $a+$b+$c+$d ?>
</td>
成為一個班級
<td class="total">
<?= $total = $a+$b+$c+$d ?>
</td>
如果您安裝了Jquery,則可以嘗試執行此操作,這將檢索total列中所有值的總數
var totalVal;
$('.total').each( function(index, element) {
totalVal += parseInt(element.html());
});
- 2 回答
- 0 關注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消