How to delete from table when chekcbox select is removed

0

What happens when selecting an item loads its data in a table, how can I do so that when I remove the select they are deleted from the table

I say, first select the item

Then, I remove the select from the checkbox and instead of being deleted it is added again

How can I make it so that by removing the select from the checkbox the item in the table is deleted.

File of the box where I select the checkbox

   folfiscal = data['datos_tabla'][index]['foliofiscal'];
                        var cell7 = row.insertCell(7);
                        cell7.innerHTML ='<td align="center"><input type="checkbox" name="leer[]"   onclick="javascript:return LLenarTablaconcepto(\''+folfisc+'\')"/>'+folfisc+'</td>';

Below I leave the code

function LLenarTablaconcepto(folfisc)
    {

        //alert('#folfisc');
      $.ajax({
            data: {"folfisc":$("#folfisc").val()},
            type: "GET",
            async: false,
            dataType: "json", //tipo de datos que devuelve json
            url: "consulta_facturas_concepto.php?foliofiscal="+folfisc,
            success: function(data)
            {
                //if( data.folio != 0 )
                if( data.encontrado != 0 )
                {
                    var id=0;
                    $(data['datos_tabla']).each(function(index)
                    {


                        var table = document.getElementById('tablaExterior').getElementsByTagName('tbody')[0];
                        var rowCount = table.rows.length;
                        var row = table.insertRow(rowCount);



                        var cell0= row.insertCell(0);
                         var folio = data['datos_tabla'][index]['descripcion'];

                        cell0.innerHTML ='<td bgcolor="blue" align="center"><a href=javascript:conceptos_erp(\''+rowCount+'\') >'+folio+'</a></td>';

                        var cell2 = row.insertCell(1);
                        cell2.innerHTML =  data['datos_tabla'][index]['valorunitario'];

                        var cell3 = row.insertCell(2);
                        cell3.innerHTML =  data['datos_tabla'][index]['cantidad'];

                        var cell4 = row.insertCell(3);
                        cell4.innerHTML =  data['datos_tabla'][index]['importe'];

                        var cell5 = row.insertCell(4);
                        cell5.innerHTML   = "";

                    id++;
                    });

                }
                else
                {

                    return false;
                }
             }

        });
    return true;
  }

Where specifically here is where you call javascript

cell0.innerHTML ='<td bgcolor="blue" align="center"><a href=javascript:conceptos_erp(\''+rowCount+'\') >'+folio+'</a></td>';
    
asked by 31.05.2018 в 18:04
source

1 answer

0

Let's see if I understand, do you want to update the table with records supplied by the select? if so, you should only empty the table every time it is called the function LLenarTablaconcepto

function LLenarTablaconcepto(folfisc)
    {

        //alert('#folfisc');
      $.ajax({
            data: {"folfisc":$("#folfisc").val()},
            type: "GET",
            async: false,
            dataType: "json", //tipo de datos que devuelve json
            url: "consulta_facturas_concepto.php?foliofiscal="+folfisc,
            success: function(data)
            {
                //if( data.folio != 0 )
                if( data.encontrado != 0 )
                {
                    var id=0;
                    var table = document.getElementById('tablaExterior').getElementsByTagName('tbody')[0];
                    table.innerHTML = '';
                    $(data['datos_tabla']).each(function(index)
                    {**texto en negrita**
                        var rowCount = table.rows.length;
                        var row = table.insertRow(rowCount);

                        var cell0= row.insertCell(0);
                         var folio = data['datos_tabla'][index]['descripcion'];

                        cell0.innerHTML ='<td bgcolor="blue" align="center"><a href=javascript:conceptos_erp(\''+rowCount+'\') >'+folio+'</a></td>';

                        var cell2 = row.insertCell(1);
                        cell2.innerHTML =  data['datos_tabla'][index]['valorunitario'];

                        var cell3 = row.insertCell(2);
                        cell3.innerHTML =  data['datos_tabla'][index]['cantidad'];

                        var cell4 = row.insertCell(3);
                        cell4.innerHTML =  data['datos_tabla'][index]['importe'];

                        var cell5 = row.insertCell(4);
                        cell5.innerHTML   = "";

                    id++;
                    });

                }
                else
                {

                    return false;
                }
             }

        });
    return true;
  }
    
answered by 31.05.2018 в 18:35