I have a table with following body. First column is a checkbox and the rest are information taken from db. The last two columns are input boxes which I can change based on quantity. I have them disabled by default. But I want them BOTH enabled when I tick the checkbox and disabled when unticked. With this code below, it enables only one id, not both. How can I achieve that?
<?php foreach ($this->sklad as $value) : ?>
<tr><td><input type="checkbox" name="checked[]" value="<?= $value['id_item']?>" onclick="enableName(this, 'quantity2<?= $value['id_item']?>');" /></td>
<td><?= $value['id_item']?></td>
<td><?= $value[$en] ?></td>
<td><?= $value['weight'] ?></td>
<td><?= $value['price'] ?></td>
<td><?= $value['code'] ?></td>
<td><?= $value['name'] ?></td>
<td><?= $value['quantity_overall']?></td>
<td><?= $value['quantity_to_sell']?></td>
<td><input type="number" name="n_to_lend" id="quantity2<?= $value['id_item']?>" min="0" max="<?= $value['quantity_overall']?>" disabled><?= $value['quantity_to_lend']?></td>
<td><input type="number" name="repair" id="quantity2<?= $value['id_item']?>" min="0" max="<?= $value['quantity_overall']?>" disabled><?= $value['repair']?></td>
</tr>
<?php endforeach; ?>
</tbody>
*
<script type="text/JavaScript">
function enableName(ctrl, txtId) {
if (ctrl.checked)
$('#' + txtId).removeAttr('disabled');
else
$('#' + txtId).attr('disabled', 'disabled');
}
</script>
*