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

  $.ajax({
    data:  parametros,
    url:   "busTipoPol/data.php",
    type:  "post",
    contentType: false,
    processData: false,
    beforeSend: function () {
      alLoad("Consultando...")
    },
    success: function (jsonPhp) {
      const jsonJS = JSON.parse(jsonPhp);

      tblClear("tblTipoPol");
      jsonJS.tipopol.forEach(function(i){
        addRowTipoPol(i.tp_cod, i.tp_nom);
      });

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

      $("#tblTipoPol tbody #btnSelecTipoPol").click(function() {
        selecTipoPol(a, $(this).parents("tr"));
      });

      alClose();
    }
  });
}

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

function selecTipoPol(a, tr) {
  if (inputTipoPol == "numTipoPol") {
    document.thisform.numTipoPol.value = tr.find("td:eq(0)").text();
    $("form[name='thisform'] #numTipoPol").trigger("change");
  } else {
    $("#"+inputTipoPol).val(tr.find("td:eq(0)").text());
    $("#"+inputTipoPol+"Nom").val(tr.find("td:eq(1)").text());
  }

  $("#pills-"+a+"-tab").click();
  $('html, body').animate( { scrollTop : 0 }, 500 );
  tblClear("tblTipoPol");
}