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 120283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:47:12+00:00 2026-05-11T03:47:12+00:00

I have two functions to add and remove table rows that contain a form

  • 0

I have two functions to add and remove table rows that contain a form input element. They both work fine, but I have a problem in that I need to show a Remove button input only on subsequently created table rows. My two function are as as follows:

function addRow(table_id){ var clone; var rows=document.getElementById(table_id).getElementsByTagName('tr'); var index=rows.length; var tbo=document.getElementById(table_id).getElementsByTagName('tbody')[0]; clone=rows[index-1].cloneNode(true); tbo.appendChild(clone); }  function delRow(table_id,button){ var row = button.parentNode.parentNode; var tbo = document.getElementById(table_id).getElementsByTagName('tbody')[0];    tbo.removeChild(row); } 

and the html content is:

<form> <table id='mytab'> <tr> <td>Upload File <input type='file' name='uploadfile[]' onchange='addRow('mytab')' /> <input name='del_row' type='button' value='Remove Row' onclick='delRow('mytab',this)'/></td> </tr> </table> </form> 

I am by no means a Javascript expert – more of a newbie – so I’m struggling to come up with a solution.

  • 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. 2026-05-11T03:47:13+00:00Added an answer on May 11, 2026 at 3:47 am

    I’m assuming that you are trying to avoid having the remove button in the first row, but need it there now because you think that to get it in subsequent rows, you need to have it in the row that you are cloning. If, instead, you just insert new HTML for both the upload and delete button inputs in the addRow method you can avoid the clone entirely and it won’t matter what your original row contains.

    function addRow(table_id){    var table = document.getElementById(table_id);    var row = table.insertRow(table.rows.length);    var cell = row.insertCell(0);    var template = table.rows[0].cells[0].innerHTML;    cell.innerHTML = template + '<input type='button' value='Remove Row''                  + ' onclick='delRow(\'' + table_id + '\',this);' />' } 

    This still uses the first row as the template, but you can remove the button from it as it is added by appending to the existing text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two functions that I'm using to add or remove slashes from a
I have two PHP functions to calculate the relation between two texts. They both
I have two input in example and after add new input remove(or empty) values
I have two functions that have different enough logic but pretty much the same
I have two functions in an ActionScript class, they are: private function loaderCompleteHandler(event:Event):void {
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
I have two Python functions, both of which take variable arguments in their function
So I have two jquery functions that bassically do the same, but on 2
I have two select lists that each display users and two buttons (add and
I have an interface that has ~16 input field boxes. They are all declared

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.