1
votes

By changing the state of the table rows I want the user to stop seeing them. I change the state on several lines at once. So I want to change the state of these rows I want to remove them from the table and I'm doing this:

function inserir_registo()
{    
var Ids = [];
$("input[name^='teste1']").each(function() {Ids.push(this.value)});

var EstadoFinals = [];
$("select[name^='EstadoFinal1']").each(function() {EstadoFinals.push($(this).val())});

var dadosajax = {
 'Id[]' : Ids,
 'EstadoFinal[]' : EstadoFinals
};
$.ajax({
    url: './encomendaaprovada',
    type: 'POST',
    cache: false,
    data: dadosajax,
    error: function(){
      $(".error_message").removeClass('hide');
    },
    success: function(result)
    { 
  for( var i = 0; i < Ids.length; i++){ 
    if(dadosajax.EstadoFinal != '2'){
    Ids.remove();
   } 
}
  }
 });
}

The code I am using to remove is this from the above function:

var Ids = [];
$("input[name^='teste1']").each(function() {Ids.push(this.value)});

success: function(result)
{
  for( var i = 0; i < Ids.length; i++){ 
if(dadosajax.EstadoFinal != '2'){
Ids.remove();
  } 
}

return this error:

?preview_id=2501&preview_nonce=dd04e65715&preview=true:784 Uncaught TypeError: Ids.remove is not a function at Object.success (?preview_id=2501&preview_nonce=dd04e65715&preview=true:784) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at A (jquery.min.js:4) at XMLHttpRequest.

But it's not removing, can it help?

1

1 Answers

0
votes

I solved my problem this way:

for( var i = 0; i < Ids.length; i++){ 
  if(dadosajax.EstadoFinal != '2'){
   Ids.splice($.inArray(Ids[i], Ids), 0);
   $('tr[id="'+ Ids[i] +'"]').remove();
  }
}