How do I make an interaction between two tables with AJAX?

0

I need to make an interaction between two tables in a side tab, where initially an "answer" table is hidden and the "question" table will be available and as soon as in input of search above them I type something via AJAX it will automatically appear in the "question" table, until then I resolved

How to hide the second table which is the one I want to appear only after I click on an item? That is, the question from the first table and the first table sum at this point.

    
asked by anonymous 16.08.2016 / 22:09

1 answer

1

To know which line you selected you can do the following in the html:

    <table id="table">
 <tr id="1">
  <td>A</td>      
  <td>B</td>      
 </tr>
 <tr id="2">
  <td>C</td>      
  <td>D</td>      
  </tr>    
</table>

In jquery to get this same line you can do the following

$('tr[id=' + id + ']').remove(); 
// id será o valor que queres passar no caso é 2 , neste caso vai apagar a linha

example in a function:

function qualLinha(){
$('#table tr').click(function (event) {
      alert($(this).attr('id')); //alerta qual foi o id da linha que selecionaste
 });
}
    
31.03.2017 / 16:54