-1
I have an array of checkboxes generated and rows of tables that have the same class - class starts at 1 and increases in 1 as more elements are recovered.
Explanation Succinct: I need that when I click on the checkbox with class= 1,line('td') with class=1 (or class with matching value depending on the value of the checkbox class), appear on the screen for the user, both are already generated on the client side, but the line is property display:None in css, I need to overwrite this property, so when you click on the checkbox the line corresponding to it appears on the user screen.
Editing : PHP code that generates the elements for the client side Below:
$valorCheck =1;
$result="SELECT * FROM indicador WHERE nome LIKE '%$id%' ORDER BY nome";
$resultado = mysqli_query($dbc,$result);
echo "<br/>";
echo "<table id=\"resultadoPesquisa\" class='table table-responsive' align='center'>
";
while($row_indicador = mysqli_fetch_assoc($resultado)) {
echo "<tr>";
echo ("<td>" . $row_indicador['nome'] . "</td>");
echo "<td>";
echo "<div>";
echo("<input class=\"checkbox1 $valorCheck\" name='check[]' type='checkbox' id='' value='" . $row_indicador['nome'] ."'/>");
echo("<span></span>");
echo "</div>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo ("<td id='' class='definicaoIndPesquisa $valorCheck'>");
echo("<h7>". $row_indicador['desc_ind'] ."</h7><br/>");
echo("<h5>Equaçao : ". $row_indicador['equacao'] ."</h5><br/>");
echo ("</td>");
echo "</tr>";
$valorCheck ++;
}
echo "</table>";
Client-side generated Html code (small example):
.definicaoIndPesquisa{
display:none;
}
<tr>
<td>Carne bovina de corte</td>
<td>
<div><input class="checkbox1 1" name="check[]" id="" value="Carne bovina de corte" type="checkbox"><span></span></div>
</td>
</tr>
<tr>
<td id="" class="definicaoIndPesquisa 1">
<h7>Indicador para testes</h7> <br>
<h5>Equaçao : Custo Operacional Efetivo*Custos Fixos</h5>
<br>
</td>
</tr>
<tr>
<td>Bovino (kg*Pa)</td>
<td>
<div><input class="checkbox1 2" name="check[]" id="" value="Carne bovina de corte" type="checkbox"><span></span></div>
</td>
</tr>
<tr>
<td id="" class="definicaoIndPesquisa 2">
<h7>Indicador teste</h7> <br>
<h5>Equaçao : 2*Custos Fixos</h5>
<br>
</td>
</tr>
Young man, we need to see how the code is organized and not a layout image.
– Jéf Bueno
OK, I’ve put the server-side code
– Vinicius Gularte
Not from the server, man. Just an example of what your TD and Checkboxes structure looks like. Your problem is super simple, but without a [mcve] it is impossible to write a good answer.
– Jéf Bueno
The structure is generated in PHP itself. Edited Question.
– Vinicius Gularte
Note that while is once run at an increment in the id of both input checkbox and table td.
– Vinicius Gularte
Young man, create a small example, a [mcve]. You don’t need to put your original code, just as it is at the end.
– Jéf Bueno
Write a small HTML of how the generated code looks.
– Jéf Bueno
A small example of the generated code has been added
– Vinicius Gularte
It has two elements with same
id
? This is completely wrong,id
must be unique.– Jéf Bueno
i know.. I tried to do a gambiarra that did not go anything right, I believe that the generated value should be added to a class for both
– Vinicius Gularte
But why don’t you use
class
? Or adata-*
?– Jéf Bueno
I needed that when I clicked on the checkbox, the line corresponding to it would appear, since it is something generated based on the database of my system
– Vinicius Gularte
I tried to create a "relationship of the id of both" but has no sense I admit, now I’m running out of time to deliver this to my boss
– Vinicius Gularte
Look, young man. If you spend about 10 minutes to describe in detail your problem, make a complete and executable example and show how the table is, I’m sure I can help you. If you don’t do this it will take a huge effort to be able to help (so far there have been 7 comments).
– Jéf Bueno
What is missing for understanding the problem?
– Vinicius Gularte
describe in detail your problem, make a complete and executable example and show how the table is
– Jéf Bueno
The "small example" is ok, it just needs to be executable... You can’t understand if each line will be an item or if it is a pro checkbox line and a pro item...
– Jéf Bueno
Young man, I left you an answer. See if you’ll answer
– Jéf Bueno