2
I’m getting a lot of Javascript, I’ve tried several ways but I’m not getting it...
I have a structure like this:
I want that when the first checkbox is checked, it multiplies the first price with the first quantity. And when it is unchecked it zeroes the multiplication. Vice versa to the other checklists.
The quantities of lines are fixed, they will always be these. At the end make the sum of all the values and add up the total.
my PHP code looks like this:
<table id="table1" width="100%" border="1">
<tr>
<th></th>
<th>Produto</th>
<th>Preço</th>
<th>Quantidade</th>
<th>Subtotal</th>
<th></th>
</tr>
<tr align="center">
<td></td>
<td><?php echo $linha_query2['produto']; ?></td>
<td class="td_preco"><?php echo $linha_query2['preco']; ?></td>
<td class="td_qt"><input name="qt2" id="qt2" value="1"/></td>
<td class="td_sub"><input name="sub2" id="sub2" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch2" value="ch2"></td>
</tr>
<tr align="center">
<td></td>
<td><?php echo $linha_query3['produto']; ?></td>
<td class="td_preco"><?php echo $linha_query3['preco']; ?></td>
<td class="td_qt"><input name="qt3" id="qt3" value="1"/></td>
<td class="td_sub"><input name="sub3" id="sub3" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch3" value="ch3"></td>
</tr>
<tr align="center">
<td></td>
<td><?php echo $linha_query4['produto']; ?></td>
<td class="td_preco"><?php echo $linha_query4['preco']; ?></td>
<td class="td_qt"><input name="qt4" id="qt4" value="1"/></td>
<td class="td_sub"><input name="sub4" id="sub4" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch4" value="ch4"></td>
</tr>
<tr align="center">
<td></td>
<td><?php echo $linha_query5['produto']; ?></td>
<td class="td_preco"><?php echo $linha_query5['preco']; ?></td>
<td class="td_qt"><input name="qt5" id="qt5" value="1"/></td>
<td class="td_sub"><input name="sub5" id="sub5" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch5" value="ch5"></td>
</tr>
<tr align="center">
<td></td>
<td><?php echo $linha_query6['produto']; ?></td>
<td class="td_preco"><?php echo $linha_query6['preco']; ?></td>
<td class="td_qt"><input name="qt6" id="qt6" value="1"/></td>
<td class="td_sub"><input name="sub6" id="sub6" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch6" value="ch6"></td>
</tr>
<tr align="center">
<td></td>
<td>
<span class="carregando">Aguarde, carregando...</span>
<select name="id_lub" id="id_lub">
<option value="">Nenhum</option>
<?php
$query = "SELECT * FROM lub ORDER BY lub";
$result_query = mysqli_query($conn, $query);
while($row_query = mysqli_fetch_assoc($result_query) ) {
echo '<option value="'.$row_query['id_estoque'].'">'.$row_query['lub'].'</option>';
}
?>
</select>
</td>
<td class="td_preco>
<span name="valor_unitario" id="valor_unitario"></span>
</td>
<td class="td_qt"><input name="qt7" id="qt7" value="1"/></td>
<td class="td_sub"><input name="sub7" id="sub7" readonly/></td>
<td class="td_ch"><input type="checkbox" name="ch7" value="ch7"></td>
</tr>
</table>
<input name="total" id="total" readonly/>
Could someone help me?
Please do not post PHP in questions about Javascript, this only generates unnecessary work for those who are trying to help. Post the HTML received by the client, not the source code.
– Andre
Okay. I thought it would help to understand the structure of my site view the id’s I’m using and etc., because there might be error in something and so the JS does not perform...
– Nosredna