Can sum total from checked and input value

Thanks to those who helped
that can be done, the item checked Total Price appears.,
If you don’t get it, the item is checked and the quantity is entered but the total price does not appear according to the order quantity entered.

Desired behaviour: the total price corresponds to the price per checked item multiplied by the quantity.

TotalPrice = PricePerItem * Numberoforders

The total also corresponds to the number of items checked.

JavaScript Code:

<script type="text/javascript">
function UpdateCost() {
  var sum = 0;
  var gn, elem;
  for (i=0; i<<?php echo $wapakpak ?>; i++) {
    gn = 'sum_m_'+i;
    elem = document.getElementById(gn);
    // tambah code
    jumlah = document.getElementById(jml);
    
    if (elem.checked == true) { 
        sum += Number(elem.value);
    }
  }
  document.getElementById('totalcost' ).value = sum.toFixed(0);
}
window.onload=UpdateCost
</script>

PHP / HTML Code

$sadsdsd = $db->prepare("SELECT count(*) FROM sw_datafasilitas");
$sadsdsd->execute();
$rowaas = $sadsdsd->fetch(PDO::FETCH_NUM);
$wapakpak=$rowaas[0];

<div class="card" style="width: 10rem; float: left; margin: 40px;">
<img src="/image_building/<?php echo $row['image']; ?>" class="card-img-top" alt="">
<div class="card-body">
<h5 class="card-title"><?php echo $row['fasilitas_name'];?></h5>
<p class="card-text"><?php echo rupiah($row['price_harga']);?> / <?php echo $row['satuan_harga'];?></p>
<input type="checkbox" name="total_fasilitastambahan[]" value="<?php echo $row['price_harga'] ?>" id="sum_m_<?php echo $i ?>" onclick="UpdateCost()" class="btn btn-warning">
<p><label>Jumlah Pesanan</label><input type="number" name="jml[]" id="jml" class="form-control" /></p>
</div>
</div>

Demo Apps Interface: