multiplication in dinamic row
hello Jqueryer,
how can i make multiplication in dinamic row, i just succes make it in the first row, hope fully by image can make you understand what my problem,
and this is my code view
- <table class="table table-bordered">
- <tr>
- <th><input class='check_all' type='checkbox' onclick="select_all()"/></th>
- <th>#</th>
- <th>Kode Barang</th>
- <th>Nama Barang</th>
- <th>Stock</th>
- <th>Jumlah</th>
- <th>Harga</th>
- <th>Total</th>
- </tr>
- <tr>
- <td><input type='checkbox' class='case'/></td>
- <td><span id='snum'>1.</span></td>
- <td><input class="form-control" type='text' id='kodebarang_1' name='kodebarang[]'/></td>
- <td><input class="form-control" type='text' id='namabarang_1' name='namabarang[]' readonly /></td>
- <td><input class="form-control" type='text' id='stock_1' name='stock[]' readonly /></td>
- <!---all i need is how do i make multiplication auto when user add row-->
- <td><input class="form-control" type='text' id='jumlah_1' name='jumlah[]' onkeyup="hitung2();" /> </td>
- <td><input class="form-control" type='text' id='harga_1' name='harga[]' onkeyup="hitung2();" /> </td>
- <td><input class="form-control" type='text' id='total_1' name='total[]'/> </td>
- </tr>
- </table>
- <button type="button" class='btn btn-danger delete'>- Delete</button>
- <button type="button" class='btn btn-success addmore'>+ Add More</button>
- <button type="submit" class="btn btn-primary">Submit</button>
-
and this is my jquery multiplication
- function hitung2() {
- var a = $("#jumlah_1").val();
- var b = $("#harga_1").val();
- c = a * b; //a kali b
- $("#total_1").val(c);
- }
i think my problem is how to make it in array ? thanks for any respon, Thanks