亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用javascript獲取表中的數據

用javascript獲取表中的數據

PHP
繁花不似錦 2021-05-05 13:20:17
我想檢索表中的數據,然后將其制成圖表請幫助如何從整體上檢索總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());

});


查看完整回答
反對 回復 2021-05-28
  • 2 回答
  • 0 關注
  • 162 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號