1
I have an HTML table that gets the values from the database. Each row of the table, when clicked on the icon need to take the values of this line and when opening the modal show this information in the modal.
When clicked on this edit icon I need to take the value of the reference line [vlor Scheduled] | [Dt Vencto] | [Document], to display in the modal.
The problem is, as the values of these lines are dynamic I can’t assign a id
for <td>
to be able to catch it with JS.
<table class="table table-sm table-bordered table-responsive">
<thead>
<tr>
<th>Documento</th>
<th>Vlr Programado</th>
<th>Dt Vencto</th>
<th colspan="2" class="text-center">Ações</th>
</tr>
</thead>
<tbody><tr>
<td>FR212</td>
<td>500</td>
<td>2019-01-18</td>
<td align="center">
<a id="omdleditreceita" data-idparcela="3"><i class="fas fa-edit"></i></a>
</td>
</tr>
<tr>
<td>FR212</td>
<td>500</td>
<td>2019-02-17</td>
<td align="center">
<a id="omdleditreceita" data-idparcela="4"><i class="fas fa-edit"></a>
</td>
</tr>
</tbody><tbody>
<tr>
<td colspan="9" align="center">
<div class="pagination-wrap">
<ul class="pagination"><li><a href="/sistema/instancias/receita/add-data.php?page_no=1" style="color:red;">1</a></li></ul> </div>
</td>
</tr>
</tbody>
</table>
Do you have any way of doing this procedure?
There are several ways, but I don’t understand exactly what the problem is
– BrTkCa
Your question is unclear but I think I get it. You need to add the event into a fixed element to watch the click from it:
$(document).on('click','#btnPrepend',function(){//do something})
https://stackoverflow.com/questions/34896106/attach-event-to-dynamic-elements-in-javascript– edson alves
Post the JS you tried to do too...
– fernandosavio
Because you’re repeating id’s
id="omdleditreceita"
? An id is equal CPF, must be unique.– Sam
"...on each line need to pick up to display on a modal..."... "catch" oq? The first paragraph of your question is very confusing.
– Sam
I edited the question, about the
id
is repeating is just to exemplify what the browser is rendering. @Sam.– JB_
@edsonalves saw here this topic but I did not understand it very well.
– JB_