Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:38:28+00:00 2026-05-31T18:38:28+00:00

I have a php table and i want the ability to delete rows of

  • 0

I have a php table and i want the ability to delete rows of my choice but i am not sure how to go about this. Here is my javascript for deleting:

// When a delete button is pressed in one of the rows 
function deleteCurrentRow(whatrow)
{
  //deletes the approriate row according to what button was pressed
  if (hasLoaded) {
    var delRow = whatrow.parentNode.parentNode;
    deleteRows(delRow);//sends the row for deletion to the function to be deleted
  }
}



function deleteRows(rowforDeletion)
{
  if (hasLoaded) {

      var rowPos = rowforDeletion.sectionRowIndex;//postion of the row for deletion
      rowforDeletion.parentNode.deleteRow(rowPos);//deletes row
      increment = increment -1;

  }
}

Here is my php table:

<table border="1" cellspacing="5" id="tblmarkscheme" style="float: center;">
  <thead>
    <tr>
      <th colspan="5">Template</th>
    </tr>
    <tr>
      <th>Mark</th><th>Criteria</th><th>Delete</th>
    </tr>
  </thead>
  <tbody>
    <?php
      $query = "SELECT maxMark, criteria FROM mark ";
      $result = mysql_query($query);


      while ($row = mysql_fetch_array($result))
      { 
        echo "<tr>";
        echo "<td>" ."<input type = text name = text size = 1 id = mark value = ". $row['maxMark'].">" ."</td>";
        echo "<td>"."<textarea>".$row['criteria']. "</textarea>"."</td>";
        echo "<td>"."<input type = button value = Delete onclick = deleteCurrentRow(this);/>"."</td>";
        echo "</tr>";

      }


    ?>

  </tbody><!--elements added onload and when button pressed -->
</table>

I want to delete individual rows of the table with a press of a button

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:38:29+00:00Added an answer on May 31, 2026 at 6:38 pm

    here’s an example; if you click on a button, it’s row gets deleted:

    <!DOCTYPE HTML>
    <html>
        <head>
            <script type="text/javascript">
                var p = {
                    deleteRow: function(row) {
                    document.getElementById("mytable").deleteRow(row.rowIndex);
                    }
                };
            </script>
        </head>
        <body>
            <table id="mytable">
                <tr>
                    <td><input type="button" value="row1" onclick="p.deleteRow(this)"/></td>
                </tr>
                <tr>
                    <td><input type="button" value="row2" onclick="p.deleteRow(this)"/></td>
                </tr>
            </table>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this php function, which I want to convert to javascript function, but
I have a table that's generated by a normal PHP loop. What I want
This is for MySQL and PHP I have a table that contains the following
I have a problem with sorting items in table in PHP. Here is what
I have to following code: http://www.nomorepasting.com/getpaste.php?pasteid=22987 If PHPSESSID is not already in the table
Excuse the terrible question title. I have this PHP string and want to check
I have a php variable called $VrHistorySlider , defined like this: $VrHistorySlider.='<table border=0><tr><td>(oldest)</td><td style=padding:0px
In my PHP web application, I want to have the ability to perform the
I have http://communitychessclub.com/games-nu.php with a game scores table. And I want the user to
I have a PHP page that returns an HTML table like this: <table> <tr>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.