4
I am in need of a help to format a <td>
according to the outcome of select
PHP. I thought about using jQuery but I don’t know much about it.
<tr class="">
<td class=""><?php echo ($row['Id_acordo']); ?></td>
<td class=""><?php echo ($row['Contrato']); ?></td>
<td class=""><?php echo ($row['Carteira']); ?></td>
<td class=""><?php echo ($row['DataPgto']); ?></td>
<td class=""><?php echo ($row['Valor']); ?></td>
<td class=""><?php echo ($row['AvistaOuParcelado']); ?></td>
<td class=""><?php echo ($row['QuitacaoOuAtualizacao']); ?></td>
<td class=""><?php echo ($row['FormaEnvio']); ?></td>
<td class=""><?php echo ($row['Recuperador']); ?></td>
<td class=""><?php echo ($row['Observacao']); ?></td>
<td class=""><?php echo ($row['Cadastrado']); ?></td>
</tr>
The tags <td>
I need you to change class according to the condition:
<?php if($row['Cadastrado'] == '0'){ ?>
<script>$('td').addClass("success");</script>
<?php }else{ ?>
<script>
$('td').removeClass("success");
$('td').addClass("danger");
</script>
<?php } ?>
Only it either paints everything by adding the two classes in the tag <td>
or add none. Example below:
<td class="success danger">16</td>
I’ve tried instead of if
else
put two loops of if
, but it wasn’t.
If possible put only in jQuery without integration with the <?php>
, because I would like him to update himself with the function $(document).ready
.
From what I understand, you want to color the lines of your table according to the result that comes from the bank? For example Registered ==0 blue line, registration == 1, green line and so on. That would be it?
– Marconi
In case the select and the table are on the same page and you want a real-time update, or is it coming from a form and are two different pages? If it’s two pages, you can do it by putting
ifs
within itselftd
, kind of:<td class="<?php if($row['Cadastrado'] === '0'){ echo 'success'; } else { echo 'danger'; } ?> ">16</td>
. Now if you’re on the same page, you’ll need to use Ajax.– gustavox
On the same page are the Select and the table, and really the intention is to update in real time. I’ll see how to do in ajax. Thank you, gustavox And that’s really it Marconi, I want to paint the td according to the values 123. Thank you.
– user3275937