Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
How to link a dynamic url to the <td> tag in jquery?

I have a child row in data table row , and I am trying to add a dynamic link to that cloud row's heading, by dynamic link I mean the URL will be depending the value of the cell

For example: let say the URL is http://example.com/delete.php and the value of d[0] is 123456789 then I want to append it to the URL making the complete URL something like this http://example.com/delete.php?account=123456789and link it to the text Delete Account

function format(d){
 
     // `d` is the original data object for the row
     return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' +
         '<tr>' +
             '<td>Active Indicators:</td>' +
             '<td>' + d[5] + '</td>' +
         '</tr>'+
         '<tr>' +
             '<td>Delete Account</td>' +
             '<td>' + d[0] + '</td>' +
         '</tr>'
     '</table>';  
}

Is it possible to do something like this? if so how does one go about it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Consider the following.

function makeTable(tableData, target) {
  var table = $("<table>", {
    cellspacing: 0,
    border: 0,
    id: "myData"
  }).css("padding-left", "50px");
  var row;
  $.each(tableData, function(k, v) {
    row = $("<tr>", {
      "data-id": v.accountId
    }).appendTo(table);
    $("<td>").html("Active Indicators:").appendTo(row);
    $("<td>").html(v.indicators).appendTo(row);
    $("<td>", {
      class: "remove"
    }).html("Delete").appendTo(row);
  });
  if (target != undefined) {
    table.appendTo(target);
  }
  return table;
}

makeTable(d, $("#results"));

$(".remove").on("click", function(event) {
  var row = $(this).closest("tr");
  $.get("http://example.com/delete.php", {
    account: row.data("id")
  }, function(result) {
    alert("Account " + row.data("id") + " Deleted");
    row.remove();
  });
});

You may need to adjust your Table Data. You didn't provide an example of your data, so I am not sure how it's formatted.

[{
  accountId: 1001,
  accountName: "First American Trust",
  indicators: "End"
}];
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda