Getting HTML table data from JSP

Asked

Viewed 75 times

0

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

The goal is to choose an air ticket among all loaded.

I intend 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 the Table taking information from only one line to mount the request.

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, creates a Function that I called buying receiving your ID, and then makes all treatment via JS or Jquery.

But easy can still 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 by taking this ID, then make your logic.

0

Good morning Lucas,

  1. When loading the air tickets, load the Ids as well, 'cause you’re gonna need them;

  2. In the "buy" link, call a method passing the ID as a parameter of the passage;

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.