2
Good afternoon
I’m setting up a table with the following code
<table align="center" cellpadding="10" id="user_table" class='table table-striped table-advance table-hover'>
<tr>
<th>NOME</th>
<th>C.P.F.</th>
<th>IDENTIDADE</th>
<th>TEL.</th>
<th>E-MAIL</th>
<th style='text-align: center'>MARCAR</th>
</tr>
<?php
while ($row=mysql_fetch_array($select))
{
?>
<tr id="row<?php echo $row['id_paciente'];?>">
<td > <?php echo $row['nome'] . " " . $data_consulta . " " . $id_m_h;?></td>
<td > <?php echo $row['cpf'];?></td>
<td > <?php echo $row['identidade'];?></td>
<td > <?php echo $row['tel_01'];?></td>
<td > <?php echo $row['email'];?></td>
<td style='text-align: center'>
<button id="id_c02b_marcar_consulta" type="button" class="btn" value="<?php echo $row['id_paciente']?>" >MARCAR <?php echo $row['id_paciente']?></button>
</td>
</tr>
<?php
}
?>
</table>
As you can see inside WHILE has the following line
<button id="id_c02b_marcar_consulta" type="button" class="btn" value="<?php echo $row['id_paciente']?>" >MARCAR <?php echo $row['id_paciente']?></button>
Normally I use the following code in java script to perform an action
$('#id_c02b_marcar_consulta').click(function ()
{
funcao_patati_patata($("#id_c02b_marcar_consulta").val(),"<?php $id_usuario; ?>","<?php $id_horario; ?>");
});
As I am in a TABLE and the Ids ARE EQUAL... the above code will only work for the first line.
My idea is that each BUTTON in the table row has to record a record containing id_user, id_patient, id_horario. I’ve got all the variables loaded.
I don’t have much experience in PHP/JAVASCRIPT/JQUERY so I’m not seeing another way to my problem. Make a javascript function that meets all lines of the table
With my current knowledge I would have to have a javascript function for each table line button. Not an option because the table is dynamic and comes from the database.
Good afternoon.. Man.. was the fastest response I’ve ever had.. Even my wife’s "YES" in marriage was quick like this :). I understood the IDEA that you spoke but with my little knowledge did not understand the class thing. The button have a class... Would I have to do another class with SOMETHING SPECIAL?? different?? It took longer writing those lines than the question itself :)
– Ricardo M.Souza
It changes absolutely nothing, it will only use class instead of using id, and the classname selector is '.' (dot) that of id is '#' (hashtag), get it ? only change what you use in id='' to inside class=', you can have as many classnames as you want, only separate by space one from the other.
– AnthraxisBR