Olá pessoal, boa tarde,
Eu tenho uma lista conforme imagem anexo 1. Ela é muito simples, é um resultado de um SELECT em Mysql retornando na minha página html/php.
Essa lista não é fixa, ou seja, ela varia quantidade de linhas e ID dos lançamentos.
Reparem que criei um checkbox no lado esquerdo de cada registro. A minha intenção é somar os valores conforme a pessoa for selecionando os ckeckbox. Eu sei como fazer isso em JavaScript através do ID do campo/objeto, porém como a lista é variável, ou seja, uma hora ela tem mais linhas, outra menos, e consequentemente os ID´s também mudam, então não estou conseguindo fazer.
Se fossem fixos seria bem simples, eu só somaria os ID x, y, z e o resultado ir para um determinado campo. Mas como fazer com uma lista que os ID´s podem mudar numa nova consulta?
Abaixo meu código e anexo o print da tela com um resultado de exemplo.
Obrigado pela ajuda!!!
<?php
session_start();
ini_set('default_charset','UTF-8');
if($_SESSION["usuario"]=="")
{
header("location:entrando.php");
}
?>
<!DOCTYPE html>
<html language="pt-br">
<head>
<meta charset="UTF-8"/>
<meta name="distribution" content="IU"/>
<title>INOCMON</title>
<link rel="stylesheet" type="text/css" href="../_css/listas.css"/>
<link rel="stylesheet" type="text/css" href="../_css/topbuttons.css"/>
<script language="javascript" src="../_js/jsfuncoes.js"></script>
</head>
<body>
<header>
<section>
<!--div><button type="image"><img src="buttconfirm.png"/></button></div-->  
<div><button type="image" onclick="location.href='console.php';"><img src="../_img/buttprevious.png" height="50%" width="50%"/></button></div>  
<!--div><button type="image" src="buttdel.png"><img src="buttdel.png"/></button></div-->
</section>
</header>
<article id="listagem">
<h2>AGRUPAR PARA REEMBOLSO</h2>
<table>
<tr>
<th>Agrupar</th>
<th>ID</th>
<th>Vencimento</th>
<th>Cliente/Fornecedor</th>
<th>Valor</th>
<th>Descrição</th>
</tr>
<?php
include("conexao.php");
$sql="SELECT *, DATE_FORMAT(Vcto,'%d/%m/%Y') AS VctoF FROM T09 WHERE (INOCMON='N' and ConciliadoLctoId=0) ORDER BY Vcto DESC";
$query=mysqli_query($con, $sql);
while($linha=mysqli_fetch_array($query))
{
echo "<tr>";
echo "<td id="."'".$linha['LctoId']."'"." class='identificador'><input type='checkbox' name="."'".$linha['LctoId']."'"."/></td>";
echo "<td>".$linha['LctoId']."</td>";
echo "<td>".$linha['VctoF']."</td>";
echo "<td>".$linha['Fantasia']."</td>";
echo "<td><p>".$linha['Vlr']."</p></td>";
// echo "<td id="."'".$linha['LctoId']."'"." class='identificador'><a href='#' onclick=jsfun01("."'".$linha['LctoId']."'".")><p>".$linha['Vlr']."</p></a></td>";
echo "<td>".$linha['Descricao']."</td>";
echo "</tr>";
}
mysqli_free_result($query);
?>
</table>
</article>
<form method="POST" id="formlink" name="nameform" action="lctobaixados.php">
<input id="forminput" type="hidden" name="nameimput"/>
</form>
</body>
</html>