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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:26:57+00:00 2026-06-13T10:26:57+00:00

I am trying to learn javascript but so far i came to a complete

  • 0

I am trying to learn javascript but so far i came to a complete stop. I’ve made a html webpage with a form on it (3 fields : Name ,Surname, Gender) and table below . i’m trying to list the data the user is typing in that form and display it below in the table using javascript (appendChild)

How could i do this easily? Examples are highly appreciated.

<HTML>
  <HEAD>
    <TITLE>Test1</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
    <link rel="stylesheet" href="style.css" type="text/css" />

    <script language="javascript">


function addRow(){
...


    </script>

  </HEAD>
  <BODY>


<form>
Name:<br>
<input type="text" id="name"><br>
Last Name: <br> 
<input type="text" id="lname"><br>
Gender: <br>
<input type="text" id ="gender"> <br>
<input type="submit" id ="submit" value="Submit" onclick="addRow()">
</form> 


<table border="1">
<tr>
<th>Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tr>
<td>test, test</td>
<td>test, test</td>
</tr>
<tr>
<td>test2, test1</td>
<td>test2, test1</td>
</tr>
</table>


  </BODY>
</HTML>
  • 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-13T10:26:58+00:00Added an answer on June 13, 2026 at 10:26 am

    Step 1:

    Give your table an identifier:

    <table border="1" id="results">
    

    Step 2:

    Get a DOM reference to this table:

    var table = document.getElementById('results');
    

    Step3:

    Make the elements you will insert:

    var row = document.createElement('tr');
    var td1 = document.createElement('td');
    var td2 = document.createElement('td');
    var td3 = document.createElement('td');
    

    Step4:

    Set their values:

    td1.innerHTML = document.getElementById('name').value;
    td2.innerHTML = document.getElementById('lname').value;
    td3.innerHTML = document.getElementById('gender').value;
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    

    Step5:

    Insert into DOM:

    table.children[0].appendChild(row);
    

    Combined, we have:

    function addRow(){
        var table = document.getElementById('results');
        var row = document.createElement('tr');
        var td1 = document.createElement('td');
        var td2 = document.createElement('td');
        var td3 = document.createElement('td');
        td1.innerHTML = document.getElementById('name').value;
        td2.innerHTML = document.getElementById('lname').value;
        td3.innerHTML = document.getElementById('gender').value;
        row.appendChild(td1);
        row.appendChild(td2);
        row.appendChild(td3);
        table.children[0].appendChild(row);
    }
    

    If you want to prepend a row, you can use something like this:

    table.children[0].insertBefore(row,table.children[0].childNodes[1]);
    

    instead of using appendChild to append the row. The rest is the same. See this example.

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

Sidebar

Related Questions

I'm completely new to the javascript and ajax world but trying to learn. Right
I'm trying to learn Javascript animations but, as I thinked, it doesn't work xD.
I am trying to learn JavaScript, but I'm struggling with a very simple example.
I'm trying to learn spring MVC, so far so good but I'm kind of
I am trying to build a simple calculator to learn javascript/jquery but seem to
Trying to learn JavaScript, makin decent progress I guess, but I'm stuck at validating
I'm trying to learn JavaScript better, and while reviewing Node.js Module source I came
I am trying to learn JavaScript but I've come across a hurdle. If the
I am trying to learn JavaScript... I have function like, I take the format
I am trying to learn javascript i have this code: x=x.replace(/^\s+|\s+$/g,); can i have

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.