I'm new to jquery. So I have two tables that I have with JSON, where I have related table ids.
I would like to know which code where I have input and show the result of the table element, when I select a row from the result table and show the result of the id component of the selection.
follow the table

Table 1
| ID ITEMS| ITEMS |
| ——– | ——– |
| 1 | 20 |
| 2 | 40 |
Table 2
| ID | NAME | Prod | ID ITEMS |
| ——– | ——– |——–|———-|
| 1 | JP |Pencil | 1 |
| 2 | BR |Pen | 2 |

$("#text").change(function(){
  $("#btn1).click(function(){
    var input = $("#input").val();
    data = "op=table2&name=" + input;
    $.get('funcs.php", data, function (response){
      console.log(response);
  
      var result = JSON.parse(response);
      var line = "";
      $.each(result.data, function(i, item) {]
        console.log(item["ID"];
        
        line = line + "<tr>";
        var column = column + "<td>" + item["NAME"] + "</td>";
        column = column + "<td>" + item["Prod"] + "</td>";
        line = line + column + "</tr>";
      )};
      $("#datatable tbody").html(line);
       $("#datatable tbody tr").click(function (){
        if ($(this).hasClass('select')) {
        $(this).removeClass('select');
       } else {
        $(this).addClass('select');
        }
        )};
         $("#btn2).click(function(){
          $('select').each(function() {
            $("#datatable tbody").html('select');
          )};
        )};
 )};

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *