how can I make button checkbox with class="terlambat" is enable when radiobutton with class="hadir" is clicked?
and how can I make it disable again when others radiobutton (class="sakit" or "izin" or "absen") is clicked?
<table class="table table-bordered table-hover">
<thead>
<tr>
<th class="col-sm-1 text-center">No.</th>
<th class="col-sm-5">Nama</th>
<th class="col-sm-4">Kehadiran</th>
<th class="col-sm-2">Keterangan</th>
</tr>
</thead>
<tbody>
<tr>
<fieldset id="kehadiran1">
<td class="text-center">1</td>
<td>Doe</td>
<td>
<label class="radio-inline"><input class="hadir0" type="radio" value="Hadir" name="kehadiran[0]">Hadir</label>
<label class="radio-inline"><input class="sakit0" type="radio" value="Sakit" name="kehadiran[0]">Sakit</label>
<label class="radio-inline"><input class="absen0" type="radio" value="Absen" name="kehadiran[0]">Absen</label>
<label class="radio-inline"><input class="izin0" type="radio" value="Izin" name="kehadiran[0]">Izin</label>
</td>
<td><label class="checkbox-inline"><input class="terlambat0" type="checkbox" value="Terlambat" name="keterangan[0]" disabled="true"> Terlambat</label></td>
</fieldset>
</tr>
<tr>
<fieldset id="kehadiran2">
<td class="text-center">2</td>
<td>Moe</td>
<td>
<label class="radio-inline"><input class="hadir1" type="radio" value="Hadir" name="kehadiran[1]">Hadir</label>
<label class="radio-inline"><input class="sakit1" type="radio" value="Sakit" name="kehadiran[1]">Sakit</label>
<label class="radio-inline"><input class="absen1" type="radio" value="Absen" name="kehadiran[1]">Absen</label>
<label class="radio-inline"><input class="izin1" type="radio" value="Izin" name="kehadiran[1]">Izin</label>
</td>
<td><label class="checkbox-inline"><input class="terlambat1" type="checkbox" value="Terlambat" name="keterangan[1]" disabled="true"> Terlambat</label></td>
</fieldset>
</tr>
</tbody></table><input class="btn btn-link" type="submit" name="submit" id="hadirSemua" value="Hadir Semua">
jquery: when the button with id="hadirSemua" is clicked, all radio button with class="hadir" will be on, and of course all checkbox with class="terlambat" will be enable
$(document).ready(function()
{
$("#hadirSemua").attr("data-type", "check");
$("#hadirSemua").click(function()
{
if ($("#hadirSemua").attr("data-type") === "check")
{
for($i=0; $i<2; $i++)
{
$(".terlambat"+$i).prop("disabled", false);
$(".hadir"+$i).prop("checked", true);
}
}
})
});
Aucun commentaire:
Enregistrer un commentaire