change value of a cell after DataTables() has been applied

change value of a cell after DataTables() has been applied

acopley89acopley89 Posts: 1Questions: 1Answers: 0
edited March 2016 in Free community support

Consider the following code

function toggleCheckMark(elem, brand){

  var cell = $(elem).html();
  if(cell == ""){

    $(elem).html("&#x2714");

    var brandval = parseInt($("#" + brand).find("td:eq(3)").html());
    var newval = brandval + 1;
    $("#" + brand).find("td:eq(3)").html("" + newval + "");
    

  } else {

    $(elem).html("");

    var brandval = parseInt($("#" + brand).find("td:eq(3)").html());
    var newval = brandval - 1;
    $("#" + brand).find("td:eq(3)").html("" + newval + "");
    
  }

}

This toggles the existence of a check mark character in a table cell which is a DataTables table.

I also have a 2nd table which summarizes some of the info in the first.

Let cell be the cell in table 1 which we have just clicked and added or removed a checkmark.

Let "#" + brand be the id of the table row in the summary table (table2).

I want to increment the value in td offset 3 (column 4), however when I have called .DataTables(); on table 2, my reference to the cell returns undefined.

My objective is to increment or decrement the value by 1. How can I achieve this after I have applied the .DataTables() method to my table.

Many Thanks

Answers

This discussion has been closed.