I need to add
if (obj1[i][0] !== d1 && row > -1) continue;
and
if (obj1[i][1] !== d2 && row > -1) continue;
depending on the value of d1 and d2 but I'm not sure what I'm doing wrong.
if statement acts as a filter it will allow only those values which assigned to d1 or d2 e.g if d1=1 it will print only values with 1 and not all values in the table.
$("#session_id, #start_date").on('change', function() {
var d1 = $( "#session_id" ).val();
var d2 = $( "#start_date" ).val();
$("#tbody").empty();
if(d1 != null || d1 != undefined){
kl1 = "if (obj1[i][0] !== d1 && row > -1) continue;";
v(kl1);
}
if(d2 != null || d2 != undefined){
var kl = "if (obj1[i][1] !== d2 && row > -1) continue;"
v(kl);
}
function v(data){
for (var i = 0; i < obj1.length; i++) {
data;
row++;
var newTr = table.insertRow(-1);
newTr.insertCell(-1).appendChild(document.createTextNode(obj1[i][1]));
newTr.insertCell(-1).appendChild(document.createTextNode(obj1[i][2]));
newTr.insertCell(-1).appendChild(document.createTextNode(obj1[i][3]));
newTr.insertCell(-1).appendChild(document.createTextNode(obj1[i][4]));
newTr.insertCell(-1).appendChild(document.createTextNode(obj1[i][5]));
}
}
});
ifstatement are in quotes"". And what you expect you happen if thecontinueis calledifstatement acts as a filter it will allow only those values which assigned tod1ord2e.g ifd1=1it will print only 1 and not all values in tablekl1to v function notkl