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

  • Home
  • SEARCH
  • 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 8770795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:37:45+00:00 2026-06-13T17:37:45+00:00

I am looking to have a function, that when pressing a button, the function

  • 0

I am looking to have a function, that when pressing a button, the function generates rows/colums.

I’ve been trying with the following code

 function addTRTD(){ 
 var tbElm = document.getElementById("tbdy");

 var newRow = document.createElement("tr");

 var newCol1= document.createElement("TD");
 var newCol2= document.createElement("TD");


 newCol1.innerHTML = "Row 1 Cell 1";
 newCol2.innerHTML = "Row 1 Cell 2";;


 newRow.appendChild(newCol1);
     newRow.appendChild(newCol2);


 tbElm.appendChild(newRow);


     newCol1.innerHTML = "Row 1 Cell 1";
     newCol2.innerHTML = "Row 1 Cell 1";



     var newRow = document.createElement("tr");
     newRow.appendChild(newCol1);
     newRow.appendChild(newCol2);

     var newCol1= document.createElement("TD");
     var newCol2= document.createElement("TD");

     newCol1.innerHTML = "Row 2 Cell 1";
     newCol2.innerHTML = "Row 2 Cell 2";


 tbElm.appendChild(newRow);
 }

but no luck. Clicking on the button I just get the following output
Row 1 Cell 1 Row 1 Cell 2

how can I get to display information of Row2?

  • 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-06-13T17:37:46+00:00Added an answer on June 13, 2026 at 5:37 pm

    The solution for me was:

    <html>
    <head>
    <title>Auto-Gen</title>
    
    <script type="text/javascript">
    
    var template = '</table>\
    <div align="justify">\
    <td>\
    <select name="name{num}" title="25">\
    <option value="1">1</option>\
    <option value="2">2</option>\
    <option value="3">3</option>\
    <option value="4">4</option>\
    <option value="5">5</option>\
    <option value="6">6</option>\
    <option value="7">7</option>\
    <option value="8">8</option>\
    <option value="9">9</option>\
    <option value="10">10</option>\
    <option value="11">11</option>\
    <option value="12">12</option>\
    <option value="13">13</option>\
    <option value="14">14</option>\
    <option value="15">15</option>\
    <option value="16">16</option>\
    <option value="17">17</option>\
    <option value="18">18</option>\
    <option value="19">19</option>\
    <option value="20">20</option>\
    <option value="21">21</option>\
    <option value="22">22</option>\
    <option value="23">23</option>\
    <option value="24">24</option>\
    <option value="25">25</option>\
    <option value="26">26</option>\
    <option value="27">27</option>\
    <option value="28">28</option>\
    <option value="29">29</option>\
    <option value="30" selected="selected">30</option>\
    <option value="31">31</option>\
    <option value="32">32</option>\
    </select>\
    </td>\
    <td>\
        {num}\
     </td>\
    </div>';
    
    var counter =0;
    
    function addNew() {
        a = document.createElement('div');
        html = template.replace(/{num}/g, counter.toString());
        a.innerHTML = html;
        var mainContainer = document.getElementById('mainContainer');
        mainContainer.appendChild(a);
        counter++;
    }
    
    </script>
    </head>
    <body>
    
    <div id="mainContainer"> </div>
    
    <div align="justify"> <input value="Add" onclick="addNew()" type="button"> </div>
    
    </body>
    </html>
    

    Thank you very much everyone for your comments and help

    Regards

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

Sidebar

Related Questions

I have been looking online to find documentation for the function in QTP and
I have a function that would use other variables, depending on what has been
I have a function that use jQuery autocomplete inside it: var row_num = 5;
I have a function that gets users from a MySQL database, the results rows
I have this function that about the following bool flag = true; while(true){ if(flag){
I'm looking for some attractive Haskell syntax for the following I have a function
i have a div and and a looping move function that translates an image
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
Im looking to have a common parent function like so void main (param 1,
I'm looking for a way to have a function such as: myFunction({Key, value}, {Key2,

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.