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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:04:48+00:00 2026-06-17T13:04:48+00:00

I am new in Javascripting language. I tried to build an application in which

  • 0

I am new in Javascripting language.
I tried to build an application in which , there is one HTML page from which I get single input entry by using Submit button, and stores in the container(data structure) and dynamically show that list i.e., list of strings, on the same page

means whenever I click submit button, that entry will automatically
append on the existing list on the same page.

HTML FILE :-

<html>
    <head>
        <script type = "text/javascript" src = "operation_q_2.js"></script>
    </head>
    <body>
        Enter String : <input type= "text" name = "name" id = "name_id"/>
        <button type="button"   onClick = "addString(this.input)">Submit</button>
    </body>
</html> 

JAVASCRIPT CODE

var input = [];

function addString(x) {
    var s = document.getElementById("name_id").value;//x.name.value;
    input.push(input);
    var size = input.length;
    //alert(size);
    printArray(size);
}

function printArray(size){
    var div = document.createElement('div');
    for (var i = 0 ; i < size; ++i) {
        div.innerHTML += input[i] + "<br />";
    }
    document.body.appendChild(div);
    //alert(size);
}

Here it stores the strings in the input Array, but unable to show on the web page. Need help please.

Tell me one more thing there is one code on given link. It also not gives desired answer. Please help me overcome from this problem.

<html>
<body>
    <script>
       function addValue(a) {
            var element1 = document.createElement('tr');
            var element2 = document.createElement('td');
            var text = document.createTextNode(a);
            var table = document.getElementById('t');
            element2.appendChild(text);
            element1.appendChild(element2); 
            table.tBodies(0).appendChild(element1);
       }
   </script>
   Name: <input type="text" name="a">
   <input type="button" value="Add" onClick='javascript:addValue(a.value)'>
   <table id="t" border="1">
       <tr><th>Employee Name</th></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-17T13:04:49+00:00Added an answer on June 17, 2026 at 1:04 pm

    In your code where you push an item to the end of your input array, you’re trying to push the array instead of the value to the array. So if your problem is that your values aren’t being appended to the page is because you’re trying to append the array that’s empty initially onto itself.

    So instead of

    input.push(input);
    

    It should be

    input.push(s);
    

    Since “s” you already declared to be the value from the text field.

    And if you’re not going to use that parameter you’re passing in, I would get rid of it.

    References: Javascript Array.Push()

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

Sidebar

Related Questions

New to rails and trying to get a one to many relationship up and
I am new to javascripting. I am using script in html code and i
New to PHP and MySQL, have heard amazing things about this website from Leo
****New to C!**** I am running Dev-C++ 4.9.9.2 on Windows 7 (64 bit build)
New to Flex, what is the nearest equivalent to the following HTML markup in
I have a javascript routine that dynamically creates an HTML page, complete with it's
New to Android and OpenCV. Been trying to to implement code from new book,
New to Django, can someone explain the difference between username=form.cleaned_data['username'] vs username=form.cleaned_data.get('username')
New to Python. In R, you can get the dimension of a matrix using
I'm really new in javascripting...(my webpage is based on jsp) I'm trying to generate

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.