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

The Archive Base Latest Questions

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

I wonder whether someone could help me please, From a tutorial I found online

  • 0

I wonder whether someone could help me please,

From a tutorial I found online which I’ve been able to adapt, I’ve put together the code below, which allows the user to dynamically add additional rows into a table following the insertion of data in the row above.

The problem I’m having is that I can only insert one more row, giving a total of two and I just can’t find out why. I’ve been back to the original here to see check that my coding is the same and except for the changes in the field name, table name and the exclusion of the ‘Add’ button I can’t see any differences to cause this problem.

I just wondered whether someone could perhaps take a look at my code please and let me know where I’m going wrong.

Javascript

<script type="text/javascript" language="javascript">
function addRow()
{
    //add a row to the rows collection and get a reference to the newly added row
    var newRow = document.all("addimage").insertRow();

    var oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='radio' name='select'>";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='text' name='title'>";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='file' name='image'>";   
}

//deletes the specified row from the table
function removeRow(src)
{
    /* src refers to the input button that was clicked. 
       to get a reference to the containing <tr> element,
       get the parent of the parent (in this case <tr>)
    */   
    var oRow = src.parentElement.parentElement;  

    //once the row reference is obtained, delete it passing in its rowIndex   
    document.all("addimage").deleteRow(oRow.rowIndex);  

}
</script>

Table Layout

<table id="addimage" style="table-layout:auto">
   <tr>
      <td width="20"><input name="select" type="radio" id="select"/></td>
      <td width="144"><input name="title" type="text" id="title"/></td>
      <td width="304"><input name="image" type="file" id="image" onchange="addRow();"/></td>
   </tr>
</table>
  • 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-28T18:21:25+00:00Added an answer on May 28, 2026 at 6:21 pm

    The new row that you are adding do not have the onchange property set, it should be:

    oCell.innerHTML = "<input type='text' name='image' onchange='addRow();'>";   
    

    Also, document.all(“addimage”) is (as far as i know) bad practice because it is not supported by all browsers. For compatibility you should also add index to insert the row in (-1 for last) and the index for the new cells. The parameter is required in Firefox and Opera, but optional in Internet Explorer, Chrome and Safari. I suggest that you change your code to something like the following:

    function addRow()
    {
        //add a row to the rows collection and get a reference to the newly added row
        var newRow = document.getElementById("addimage").insertRow(-1);
    
        var oCell = newRow.insertCell(0);
        oCell.innerHTML = "<input type='radio' name='select'>";
    
        oCell = newRow.insertCell(1);
        oCell.innerHTML = "<input type='text' name='title'>";
    
        oCell = newRow.insertCell(2);
        oCell.innerHTML = "<input type='text' name='image' onchange='addRow();'>";   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. I've put together
I wonder whether someone can help me please. I've put together this page, which
I wonder whether someone may be able to help me please. I've put some
I wonder whether someone may be able to help me please. I've been working
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone could help me please. Through the use of some online
I wonder whether someone could help me please. I've been looking through this, and
I wonder whether someone could help me please. I have put together a form
I wonder whether someone could help me please. I'm put together the following form
I wonder whether someone may be able to help me please. I've put together

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.