gimana cara mengambil beberapa data array dalam satu baris menggunakan checkbox

hasil.jpg 49.12 KB <?php
include '../koneksi.php';
$result1 = mysqli_query($koneksi,"SELECT * from issue_sementara WHERE no_doc='101' ");
echo '<form method="post" action="trans_prosess">';
echo '<table id="datatable" class="table table-striped table-bordered">';
echo '<thead>';
echo '<tr>';
echo '<th><input type="checkbox" onchange="checkAll(this)" name="chk[]" ></th>';
echo '<th>Item Code</th>';
echo '<th>Description</th>';
echo '<th>Unit</th>';
echo '<th>Stock</th>';
echo '<th width="120px">Qty</th>';
echo '</thead>';
echo '<tbody>';
$no = 0;
while($row = mysqli_fetch_array($result1)){
$no ++;
echo '<tr>';
echo "<td width='20px'><input type='checkbox' name='chkbox[]' value=".$row["item_code"]."></td>";
echo "<td><input type='hidden' value=".$row["item_code"].">".$row["item_code"]."</td>";
echo "<td><input type='hidden' name='description' value=".$row["description"].">".$row["description"]."</td>";
echo "<td><input type='hidden' name='material_unit' value=".$row["material_unit"].">".$row["material_unit"]."</td>";
echo "<td>".$row["qty"]."</td>";
echo "<input type='hidden' name='no_doc' value=".$row["no_doc"].">";
echo "<input type='hidden' name='id_pr' value=".$row["id_pr"].">";
?>
<td>
  <div class='prim-inputtt col-md-1 col-md-1 col-md-1'>
    <input type='text' class='form-control inputannya_normal' name='qty' required>
  </div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<button type="submit" name="po1" class="btn btn-default" style="background-color:#ccddff">
  <i class="fa fa-save">
  </i>
</button>
<a href="#" class="btn btn-default" style="background-color:#ffe6e6 ">
  <i class="fa fa-trash-o ">
  </i>
</a>
</form>
hasil.jpg 49.12 KB

avatar maulanamahdi
@maulanamahdi

109 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>ini maksud nya checkbox trus dapet value nya ya ??&nbsp;<br>bisa coba pakai javascript&nbsp;</div><div><br></div><pre>&lt;?php for($i=1;$i &lt;= 14; $i++) { ?&gt; &lt;div class="col-sm-2"&gt; &lt;label class="container"&gt;&lt;input type="checkbox" name="detail[0][j&lt;?= $i; ?&gt;]" data-hasil=1 class="hitungPeriode" onclick="cekini(0)"&gt;&lt;span class="checkmark"&gt;&lt;/span&gt;&lt;?= $i; ?&gt;&lt;/label&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;script type="text/javascript"&gt; function cekini(id) { var total = id; $("input[class='hitungPeriode']:checked").each(function(){ //Update total total += parseInt($(this).data("hasil")); }); $("#periode").val(total); $("input[class='hitungPeriode']:checked").val(1); } &lt;script&gt;</pre><div><br>sesuaikan dengan code nya&nbsp;</div>

avatar farah92
@farah92

49 Kontribusi 10 Poin

Dipost 3 tahun yang lalu

Tanggapan

Maksudnya satu checkbox bisa bawa 5 value yg berpeda satu value lebih dari satu data mas .

Login untuk ikut Jawaban