を計算私のHTMLコードである:私はのために(製品入力欄の25行を有するjqueryのは、ここでは、複数のボックスkeyUpイベント機能
<tbody>
<?php $x = 1; while($x < 26){ ?>
<tr>
<td><?php echo $x; ?></td>
<td>
<?php $sql_produk = mysql_query("SELECT stok.id AS id, jenis_barang.nama, stok.stok FROM stok LEFT JOIN jenis_barang ON jenis_barang.id = stok.jenisbarang_id WHERE toko = '$administrator_id' GROUP BY stok.jenisbarang_id")or die(mysql_error()); ?>
<select class="form-control select2me" name="produk_<?php echo $x; ?>">
<option value="0">Select...</option>
<?php while($row_produk = mysql_fetch_array($sql_produk)) { ?>
<option value="<?php echo $row_produk['id'] ?>"> <?php echo $row_produk['nama'] ?> (Stok Tersedia: <?php echo $row_produk['stok'] ?>) </option>
<?php } ?>
</select>
</td>
<td><input class="form-control" type="text" name="produk_custom_<?php echo $x; ?>" /></td>
<td><input class="form-control" type="text" name="qty_<?php echo $x; ?>" id="id_qty_<?php echo $x; ?>" /></td>
<td><input class="form-control" type="text" name="harga_<?php echo $x; ?>" id="id_harga_<?php echo $x; ?>" /></td>
<td><input class="form-control" type="text" name="harga_markup_<?php echo $x; ?>" id="id_harga_markup_<?php echo $x; ?>" value="0" /></td>
<td><input class="form-control" type="text" id="id_total_<?php echo $x; ?>" disabled /><input type="text" class="classtotal" value="0" name="total_<?php echo $x; ?>" id="ids_total_<?php echo $x; ?>"></td>
<td><input class="form-control" type="text" id="id_total_markup_<?php echo $x; ?>" disabled /><input type="hidden" class="form-control" value="0" name="total_markup<?php echo $x; ?>" id="ids_total_markup_<?php echo $x; ?>" ></td>
</tr>
<?php $x++; } ?>
</tbody>
<tr>
<td width="5%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="5%"> </td>
<td width="12.5%"> </td>
<td width="12.5%" style="text-align:right"><h4 style="font-weight:bold">TOTAL</h4></td>
<td width="12.5%"><input class="form-control" type="text" name="total_all" id="id_total_all" disabled /></td>
<td width="12.5%"><input class="form-control" type="text" name="total_markup_all" id="id_total_markup_all" disabled /></td>
これは私のJavaScriptコード
<script type="text/javascript">
$('.totalamountcb').change(function() {
calculateInvoiceTotals();
}).change();
function format1(n, currency) {
return currency + " " + n.toFixed(0).replace(/./g, function(c, i, a) {
return i > 0 && c !== "," && (a.length - i) % 3 === 0 ? "." + c : c;
});
}
$(document).ready(function(){
$('#id_harga_1, #id_qty_1').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_1').val());
qty =parseInt($('#id_qty_1').val());
total =qty * harga;
$('#ids_total_1').val(total);
$('#id_total_1').val(format1(total, "Rp."));
});
$('#id_harga_2, #id_qty_2').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_2').val());
qty =parseInt($('#id_qty_2').val());
total =qty * harga;
$('#ids_total_2').val(total);
$('#id_total_2').val(format1(total, "Rp."));
});
$('#id_harga_3, #id_qty_3').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_3').val());
qty =parseInt($('#id_qty_3').val());
total =qty * harga;
$('#ids_total_3').val(total);
$('#id_total_3').val(format1(total, "Rp."));
});
$('#id_harga_4, #id_qty_4').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_4').val());
qty =parseInt($('#id_qty_4').val());
total =qty * harga;
$('#ids_total_4').val(total);
$('#id_total_4').val(format1(total, "Rp."));
});
$('#id_harga_5, #id_qty_5').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_5').val());
qty =parseInt($('#id_qty_5').val());
total =qty * harga;
$('#ids_total_5').val(total);
$('#id_total_5').val(format1(total, "Rp."));
});
$('#id_harga_6, #id_qty_6').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_6').val());
qty =parseInt($('#id_qty_6').val());
total =qty * harga;
$('#ids_total_6').val(total);
$('#id_total_6').val(format1(total, "Rp."));
});
$('#id_harga_7, #id_qty_7').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_7').val());
qty =parseInt($('#id_qty_7').val());
total =qty * harga;
$('#ids_total_7').val(total);
$('#id_total_7').val(format1(total, "Rp."));
});
$('#id_harga_8, #id_qty_8').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_8').val());
qty =parseInt($('#id_qty_8').val());
total =qty * harga;
$('#ids_total_8').val(total);
$('#id_total_8').val(format1(total, "Rp."));
});
$('#id_harga_9, #id_qty_9').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_9').val());
qty =parseInt($('#id_qty_9').val());
total =qty * harga;
$('#ids_total_9').val(total);
$('#id_total_9').val(format1(total, "Rp."));
});
$('#id_harga_10, #id_qty_10').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_10').val());
qty =parseInt($('#id_qty_10').val());
total =qty * harga;
$('#ids_total_10').val(total);
$('#id_total_10').val(format1(total, "Rp."));
});
$('#id_harga_11, #id_qty_11').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_11').val());
qty =parseInt($('#id_qty_11').val());
total =qty * harga;
$('#ids_total_11').val(total);
$('#id_total_11').val(format1(total, "Rp."));
});
$('#id_harga_12, #id_qty_12').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_12').val());
qty =parseInt($('#id_qty_12').val());
total =qty * harga;
$('#ids_total_12').val(total);
$('#id_total_12').val(format1(total, "Rp."));
});
$('#id_harga_13, #id_qty_13').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_13').val());
qty =parseInt($('#id_qty_13').val());
total =qty * harga;
$('#ids_total_13').val(total);
$('#id_total_13').val(format1(total, "Rp."));
});
$('#id_harga_14, #id_qty_14').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_14').val());
qty =parseInt($('#id_qty_14').val());
total =qty * harga;
$('#ids_total_14').val(total);
$('#id_total_14').val(format1(total, "Rp."));
});
$('#id_harga_15, #id_qty_15').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_15').val());
qty =parseInt($('#id_qty_15').val());
total =qty * harga;
$('#ids_total_15').val(total);
$('#id_total_15').val(format1(total, "Rp."));
});
$('#id_harga_16, #id_qty_16').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_16').val());
qty =parseInt($('#id_qty_16').val());
total =qty * harga;
$('#ids_total_16').val(total);
$('#id_total_16').val(format1(total, "Rp."));
});
$('#id_harga_17, #id_qty_17').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_17').val());
qty =parseInt($('#id_qty_17').val());
total =qty * harga;
$('#ids_total_17').val(total);
$('#id_total_17').val(format1(total, "Rp."));
});
$('#id_harga_18, #id_qty_18').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_18').val());
qty =parseInt($('#id_qty_18').val());
total =qty * harga;
$('#ids_total_18').val(total);
$('#id_total_18').val(format1(total, "Rp."));
});
$('#id_harga_19, #id_qty_19').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_19').val());
qty =parseInt($('#id_qty_19').val());
total =qty * harga;
$('#ids_total_19').val(total);
$('#id_total_19').val(format1(total, "Rp."));
});
$('#id_harga_20, #id_qty_20').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_20').val());
qty =parseInt($('#id_qty_20').val());
total =qty * harga;
$('#ids_total_20').val(total);
$('#id_total_20').val(format1(total, "Rp."));
});
$('#id_harga_21, #id_qty_21').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_21').val());
qty =parseInt($('#id_qty_21').val());
total =qty * harga;
$('#ids_total_21').val(total);
$('#id_total_21').val(format1(total, "Rp."));
});
$('#id_harga_22, #id_qty_22').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_22').val());
qty =parseInt($('#id_qty_22').val());
total =qty * harga;
$('#ids_total_22').val(total);
$('#id_total_22').val(format1(total, "Rp."));
});
$('#id_harga_23, #id_qty_23').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_23').val());
qty =parseInt($('#id_qty_23').val());
total =qty * harga;
$('#ids_total_23').val(total);
$('#id_total_23').val(format1(total, "Rp."));
});
$('#id_harga_24, #id_qty_24').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_24').val());
qty =parseInt($('#id_qty_24').val());
total =qty * harga;
$('#ids_total_24').val(total);
$('#id_total_24').val(format1(total, "Rp."));
});
$('#id_harga_25, #id_qty_25').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_25').val());
qty =parseInt($('#id_qty_25').val());
total =qty * harga;
$('#ids_total_25').val(total);
$('#id_total_25').val(format1(total, "Rp."));
});
$('#id_harga_markup_1, #id_qty_1').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_1').val());
qty =parseInt($('#id_qty_1').val());
total =qty * harga;
$('#ids_total_markup_1').val(total);
$('#id_total_markup_1').val(format1(total, "Rp."));
});
$('#id_harga_markup_2, #id_qty_2').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_2').val());
qty =parseInt($('#id_qty_2').val());
total =qty * harga;
$('#ids_total_markup_2').val(total);
$('#id_total_markup_2').val(format1(total, "Rp."));
});
$('#id_harga_markup_3, #id_qty_3').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_3').val());
qty =parseInt($('#id_qty_3').val());
total =qty * harga;
$('#ids_total_markup_3').val(total);
$('#id_total_markup_3').val(format1(total, "Rp."));
});
$('#id_harga_markup_4, #id_qty_4').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_4').val());
qty =parseInt($('#id_qty_4').val());
total =qty * harga;
$('#ids_total_markup_4').val(total);
$('#id_total_markup_4').val(format1(total, "Rp."));
});
$('#id_harga_markup_5, #id_qty_5').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_5').val());
qty =parseInt($('#id_qty_5').val());
total =qty * harga;
$('#ids_total_markup_5').val(total);
$('#id_total_markup_5').val(format1(total, "Rp."));
});
$('#id_harga_markup_6, #id_qty_6').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_6').val());
qty =parseInt($('#id_qty_6').val());
total =qty * harga;
$('#ids_total_markup_6').val(total);
$('#id_total_markup_6').val(format1(total, "Rp."));
});
$('#id_harga_markup_7, #id_qty_7').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_7').val());
qty =parseInt($('#id_qty_7').val());
total =qty * harga;
$('#ids_total_markup_7').val(total);
$('#id_total_markup_7').val(format1(total, "Rp."));
});
$('#id_harga_markup_8, #id_qty_8').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_8').val());
qty =parseInt($('#id_qty_8').val());
total =qty * harga;
$('#ids_total_markup_8').val(total);
$('#id_total_markup_8').val(format1(total, "Rp."));
});
$('#id_harga_markup_9, #id_qty_9').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_9').val());
qty =parseInt($('#id_qty_9').val());
total =qty * harga;
$('#ids_total_markup_9').val(total);
$('#id_total_markup_9').val(format1(total, "Rp."));
});
$('#id_harga_markup_10, #id_qty_10').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_10').val());
qty =parseInt($('#id_qty_10').val());
total =qty * harga;
$('#ids_total_markup_10').val(total);
$('#id_total_markup_10').val(format1(total, "Rp."));
});
$('#id_harga_markup_11, #id_qty_11').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_11').val());
qty =parseInt($('#id_qty_11').val());
total =qty * harga;
$('#ids_total_markup_11').val(total);
$('#id_total_markup_11').val(format1(total, "Rp."));
});
$('#id_harga_markup_12, #id_qty_12').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_12').val());
qty =parseInt($('#id_qty_12').val());
total =qty * harga;
$('#ids_total_markup_12').val(total);
$('#id_total_markup_12').val(format1(total, "Rp."));
});
$('#id_harga_markup_13, #id_qty_13').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_13').val());
qty =parseInt($('#id_qty_13').val());
total =qty * harga;
$('#ids_total_markup_13').val(total);
$('#id_total_markup_13').val(format1(total, "Rp."));
});
$('#id_harga_markup_14, #id_qty_14').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_14').val());
qty =parseInt($('#id_qty_14').val());
total =qty * harga;
$('#ids_total_markup_14').val(total);
$('#id_total_markup_14').val(format1(total, "Rp."));
});
$('#id_harga_markup_15, #id_qty_15').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_15').val());
qty =parseInt($('#id_qty_15').val());
total =qty * harga;
$('#ids_total_markup_15').val(total);
$('#id_total_markup_15').val(format1(total, "Rp."));
});
$('#id_harga_markup_16, #id_qty_16').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_16').val());
qty =parseInt($('#id_qty_16').val());
total =qty * harga;
$('#ids_total_markup_16').val(total);
$('#id_total_markup_16').val(format1(total, "Rp."));
});
$('#id_harga_markup_17, #id_qty_17').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_17').val());
qty =parseInt($('#id_qty_17').val());
total =qty * harga;
$('#ids_total_markup_17').val(total);
$('#id_total_markup_17').val(format1(total, "Rp."));
});
$('#id_harga_markup_18, #id_qty_18').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_18').val());
qty =parseInt($('#id_qty_18').val());
total =qty * harga;
$('#ids_total_markup_18').val(total);
$('#id_total_markup_18').val(format1(total, "Rp."));
});
$('#id_harga_markup_19, #id_qty_19').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_19').val());
qty =parseInt($('#id_qty_19').val());
total =qty * harga;
$('#ids_total_markup_19').val(total);
$('#id_total_markup_19').val(format1(total, "Rp."));
});
$('#id_harga_markup_20, #id_qty_20').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_20').val());
qty =parseInt($('#id_qty_20').val());
total =qty * harga;
$('#ids_total_markup_20').val(total);
$('#id_total_markup_20').val(format1(total, "Rp."));
});
$('#id_harga_markup_21, #id_qty_21').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_21').val());
qty =parseInt($('#id_qty_21').val());
total =qty * harga;
$('#ids_total_markup_21').val(total);
$('#id_total_markup_21').val(format1(total, "Rp."));
});
$('#id_harga_markup_22, #id_qty_22').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_22').val());
qty =parseInt($('#id_qty_22').val());
total =qty * harga;
$('#ids_total_markup_22').val(total);
$('#id_total_markup_22').val(format1(total, "Rp."));
});
$('#id_harga_markup_23, #id_qty_23').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_23').val());
qty =parseInt($('#id_qty_23').val());
total =qty * harga;
$('#ids_total_markup_23').val(total);
$('#id_total_markup_23').val(format1(total, "Rp."));
});
$('#id_harga_markup_24, #id_qty_24').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_24').val());
qty =parseInt($('#id_qty_24').val());
total =qty * harga;
$('#ids_total_markup_24').val(total);
$('#id_total_markup_24').val(format1(total, "Rp."));
});
$('#id_harga_markup_25, #id_qty_25').keyup(function(){
<!-- Ambil nilai !-->
harga =parseInt($('#id_harga_markup_25').val());
qty =parseInt($('#id_qty_25').val());
total =qty * harga;
$('#ids_total_markup_25').val(total);
$('#id_total_markup_25').val(format1(total, "Rp."));
});
});
</script>
あります請求書)すべてのお問い合わせの合計価格の1行で
私は正常にqtの乗算コードを作成しているyのharga(harga =価格)、テーブルの下部に私は無効になっている合計入力ボックスを持って、私はそれがqty/hargaを入力したいときに、私は合計合計の合計25行を合計したい。どうやってやるの?私はここですべての提案を検索して試しましたが、それはどういう意味ですか、私は25ボックスのJavaScriptコードをループできる方法はありますか? IVEはそれを試してみましたが、それはあなたが実行中の合計を使用する必要が助け
あなたのコードは少し繰り返しすぎて読みづらいです。 – kazenorin