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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:58:39+00:00 2026-06-10T21:58:39+00:00

I am a very early beginner who is trying to do something in JavaScript.

  • 0

I am a very early beginner who is trying to do something in JavaScript.

Basically I have an HTML form where I am collecting user input. I have a submit button. When on submit, I want my values from the input to be appended to a table as a new row.

I have spent hours trying to find a direction, can someone point me in the right direction?

  • 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-10T21:58:41+00:00Added an answer on June 10, 2026 at 9:58 pm

    Since nobody else wants to (or can) provide a pure JS answer, here’s how you can do it with pure JavaScript. If some things are unclear, let me know and I’ll be happy to provide you with useful links and explain what this code does:

    HTML:

    <table id='targetTbl'>
        <tbody>
            <tr><th>Name</th><th>First name</th></tr>
        </tbody>
    </table>
    <form id='inForm'>
        <input type='text' name='name' id='name'/>
        <input type='text' name='first' id='first'/>
        <input type='submit' value='add row'/>
    </form>​
    

    JavaScript:

    document.getElementById('inForm').onsubmit = function(e)
    {
        var newRow,i;
        e = e || window.event;
        if (e.preventDefault)
        {
            e.preventDefault();
            e.stopPropagation();
        }
        e.returnValue = false;
        e.cancelBubble = true;
        newRow = '<tr>';
        for(i=0;i<this.elements.length;i++)
        {
            if (this.elements[i].tagName.toLowerCase() === 'input' && this.elements[i].type === 'text')
            {
                newRow += '<td>'+this.elements[i].value+'</td>';
            }
        }
        document.getElementById('targetTbl').innerHTML += newRow + '</tr>';
        return false;
    };
    

    In order for this to work, you need to either include this code at the bottom of your HTML file (not reccomended) to ensure the DOM has loaded before you’re trying to change things, or you’ll have to put this code inside an event handler:

    window.onload = function()
    {
        //above code goes here
    };
    

    Here’s a working fiddle

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

Sidebar

Related Questions

I'm designing a site. It is in a very early stage, and I have
Very simple + silly question: Does clojure provide multi maps? I currently have something
I'm sure this is something that AJAX gurus learn very early on, but this
I have some code I would like to execute very early in the lifecycle
It's very early in the process so i don't have any actual code to
I’m trying to write a basic ASP.NET form (using Visual Studio 2010) to submit
I'm currently reading 'Javascript Web Applications' (O'Reilly, Alex MacCaw) and very early on there's
I have a Java project, which is still in a very early stage. There
I'm very early in the iPhone development learning process. I'm trying to get my
I have bind an event on submit form on a login page. I want

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.