function buscarSubFamii(b, a){
  const parametros = new FormData();
  parametros.append("txtNom", document.formSubFamii.txtNom.value);

  $.ajax({
    data:  parametros,
    url:   "busSubFamii/data.php",
    type:  "post",
    contentType: false,
    processData: false,
    beforeSend: function () {
      alLoad("Consultando...")
    },
    success: function (jsonPhp) {
      const jsonJS = JSON.parse(jsonPhp);
      console.log(jsonJS);
      tblClear("tblSubFamii");
      jsonJS.subdeptosi.forEach(function(i){
        addRowSubFamii(i.sdep_dep,i.sdep_cod, i.sdep_nom);
      });

      $("#tblSubFamii tbody tr").dblclick(function() {
        selectSubFamii(a, $(this));
      });

      $("#tblSubFamii tbody #btnSelecSubFamii").click(function() {
        selectSubFamii(a, $(this).parents("tr"));
      });

      alClose();
    }
  });
}

function addRowSubFamii(dep,cod, nom) {
  const markup =  "<tr>"
                    +"<td>"+dep+"</td>"
                    +"<td>"+cod+"</td>"
                    +"<td>"+nom+"</td>"
                    +"<td><button class='btn btn-sm btn-warning badge' id='btnSelecSubFamii'>"+textBtnSelec+"</button></td>"
                  +"</tr>";
  $("#tblSubFamii tbody").append(markup);
}

function selectSubFamii(a, tr) {
  $("#pills-"+a+"-tab").click();
  /*if (inputProvee == "txtNit") {
    document.thisform.txtNit.value = tr.find("td:eq(0)").text();
    $("form[name='thisform'] #txtNit").trigger("change");
  } else {*/
    $("#"+inputDep).val(tr.find("td:eq(0)").text());
    $("#"+inputCod).val(tr.find("td:eq(1)").text());
    $("#"+inputCod).trigger("change");
  //}

  //$('html, body').animate( { scrollTop : 0 }, 500 );
  tblClear("tblSubFamii");
}