Get table HTML data by JSP [closed]

0

I search the data in the database and put a table in my JSP. The information is from several flights of an airline company.

The goal is to choose one air ticket among all those loaded.

I want to put a link "buy" on each line and, when clicking, make a request with the data of that line, however, I have no idea how to go through Table only one line to mount the request.

    
asked by anonymous 06.12.2018 / 02:35

2 answers

0
<table>
// loop foreach
<tr>
<td>Jill</td>
<td>Smith</td>
<td><a onclick="comprar(passa o id aqui)">COMPRAR</a></td>
</tr>  
// loop foreach
</table>

In your loop already separates a TD to create BUY button, create a function that I called to buy receiving your ID, and there it does all the treatment via JS or JQuery.

But easy still can be so by replacing the line below.      <td><a href='localhost/comprar/ID_AQUI>COMPRAR</a></td>

And in your controller you create a request using GET taking this ID, that's what makes your logic.

    
06.12.2018 / 21:38
0

Good morning Lucas,

  • When loading air tickets, it loads the IDs too, because you will need them;

  • On the "buy" link, call a method by passing the ID of the passage;

  • In the method, it makes a SELECT in the bank, searching the data of that passage, in SELECT it is clear that in the condition (WHERE) you will put the ID of the passage.

  • 06.12.2018 / 12:46