Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!