i need to get one or max three selected checkbox that i can insert into database, and also i have a id jumlah that i need to input and calculate it (jumlah*harga) show it on id hasil.
This is the jumlah * harga i tried, this is success
function sum(id) {
var harga = document.getElementById('harga-' + id).value;
var jumlah = document.getElementById('jumlah-' + id).value;
var hasil = parseInt(harga) * parseInt(jumlah);
if (!isNaN(hasil))
{
document.getElementById('total-' + id).value = hasil;
}
}
but i want, i can calculate this when i select the checkbox
This is the foreach loop
@foreach($ob as $b)
<tr>
<td>
<input type="checkbox" name="select" id="check" value=">
</td>
<td>
<input name="jumlah" id="jumlah" onkey="sum()">
</td>
<td>
<input name="harga" id="harga" onkey="sum()">
</td>
<td>
<input name="hasil" id="hasil" onkey="sum()">
</td>
</tr>
@endforeach
I need to get the selected checkbox row as data not array
Aucun commentaire:
Enregistrer un commentaire