2
I am not aware of Javascript and I am using Cakephp 3 framework. So my problem is, I have a list where each item on the list has 2 checkbox, and when I select the first checkbox for one item it would automatically select the other.
What happens is that when I select the first checkbox of the item it selects the second checkbox of the entire list and not only the second checkbox of the selected item.
This is my view:
<form action="../vendas/" method="post">
<?= $this->Form->create("carrinho", ["class " => "form-add", "action" => "carrinho", "controller" => "Produtos-Vendas"]) ?>
<button type="submit" class="btn-success btn">Carrinho (<span id="additem"></span>)</button>
<?php foreach ($produtos as $produto): ?>
<tr>
<td><?= $this->Number->format($produto->id) ?></td>
<td><?= h($produto->name) ?></td>
<td><?= h($produto->cor) ?></td>
<td><?= h($produto->tecido) ?></td>
<td><?= $this->Number->format($produto->estoque) ?></td>
<td><?= $this->Number->format($produto->preco) ?></td>
<td>
<input type="checkbox" id="checkTodos" name="check[]" class="checkbox checkTodos" value="<?php echo $produto['id'];?>">
<input type="checkbox" class="checkado" name="nome" value="<?php echo $produto['name'];?>">
</td>
</tr>
<?php endforeach; ?>
<?= $this->Form->end() ?>
</form>
Javascript:
$(".checkTodos").click(function(){
$('.checkado' && '#checkado').not(this).prop('checked', this.checked);
});
If uncheck the first is to uncheck the second tb?
– Sam