Delete a row javascript using row id

ermanno.tedeschi

Hi guys I have a table created by php in this way:

  foreach ($query as $row): ?>
                <tr id="<?php echo  $row->aic;?>" > 

                    <td><?php echo $row->aic; ?></td>
                    <td><?php echo $row->denominazione ?></td>
                    <td><?php echo $row->quantita; ?></td>
                    <td><?php echo $row->alert; ?></td>
                    <td>
                         <a id="bt_modifica"
                                class="btn btn-default btn-xs"
                                 data-toggle="tooltip" 
                                 data-placement="top" 
                                 title="" 
                                 data-original-title="Modifica">
                            <img src="<?php echo base_url(); ?>template/images/Modifica.png">
                        </a> 
                           <a id="bt_elimina>"
                                  class="btn btn-default btn-xs"
                                  data-toggle="tooltip" 
                                 data-placement="top" 
                                 title=""
                                 data-original-title="Elimina"
                                 onclick="deleteRow(<?php echo $row->aic ?>))">

                            <img src="<?php echo base_url(); ?>template/images/Elimina.png"> 
                        </a> 
                    </td>
                </tr>
            <?php 

            endforeach; ?>


            </tbody>

I need to delete row by rowId. This table has the dynamics id. The columns ids are the same id of the sql table; in effect aic is id of sql table! In this way I are sure that the HTML row id is unique. This is script

function deleteRow(rowID)
{   var row = document.getElementById(rowID);
    row.parentElement.removeChild(row);
        alert(rowID);

            }
}

this code don't delete row.

fajarkoe

Change this:

onclick="deleteRow(deleteRow(<?php echo $row->aic ?>))">

to

onclick="deleteRow(<?php echo $row->aic ?>)">

Another potential issue is that this:

<?php echo $row->aic ?>

may not be a number. So, you need to quote it. That is, change:

onclick="deleteRow(<?php echo $row->aic ?>)">

to:

onclick="deleteRow(\"<?php echo $row->aic ?>\")">

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

delete row id using Contentprovider

From Dev

Delete Table row using javascript

From Dev

Delete row of the table using javascript

From Dev

To delete a row dynamically from a table using javascript

From Dev

Laravel delete row with no 'id'

From Dev

Delete a row with JavaScript

From Dev

MySQL delete row if id is found in another row

From Dev

Delete multiple rows while using the id from the row before

From Dev

jqGrid Delete Row with ID passed

From Dev

row number not update when delete a row in JavaScript

From Dev

Delete TABLE row TR with JavaScript

From Dev

How to edit and delete the row in Javascript?

From Dev

Delete blank row using For Next

From Dev

Delete row using where clause

From Dev

delete row in googlesheet using googlesheetapi

From Dev

Using case to delete data row

From Dev

How to delete row using php?

From Dev

Edit specific row of a table using id of that row

From Dev

delete row using delete button in ListView

From Dev

How to change table row ID dynamically based on the row delete?

From Dev

How to change table row ID dynamically based on the row delete?

From Dev

How do I delete a row from Sqlite using ID where my ID is binary data (GUID)

From Dev

AJAX Delete row in table with PHP id selected

From Dev

jQuery delete table row by dynamic id

From Dev

Delete Row By id from SQLdatabase in Android

From Dev

How to delete a row in dojo EnhancedGrid using row index not by using selection

From Dev

Update row on datatable using ID

From Java

Table add row, edit row, save row, delete row Using HTML, CSS, JS

From Dev

Delete row + the following 2 rows if a certain row name using UNIX

Related Related

HotTag

Archive