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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:19:08+00:00 2026-06-16T00:19:08+00:00

I was trying to iterate in loop through text boxes and assign values to

  • 0

I was trying to iterate in loop through text boxes and assign values to it. I have created three array list ids[],id1s[],id2s[].

values in ids[] have to be populated in the first column and its coming fine. but values in id1s[] and id2[] need to be populated in the 2nd and 3rd column. loop run 5 times. first times it populating in the first row, but from next time onward its overriding the first row.. and not coming to second row

Below is my code :–

<!DOCTYPE html>
  <html>
    <head>
      <script>
        function start()
        {
          var ids = ["A", "B", "C", "D", "E"];
          var id1s = [1,2,3,4,5];
          var id2s = [6,7,8,9,10];
          for (var i = 0; i < ids.length; i++){
            var value=ids[i];
            addrow(value);
            addData(id1s[i], id2s[i]);
          }
        }

        function addrow(value)
        {
          var test1 = value+'1';
          var test2 = value+'2';
          var TABLE = document.getElementById('tableId');
          var BODY = TABLE.getElementsByTagName('tbody')[0];
          var TR = document.createElement('tr');
          var TD1 = document.createElement('td');
          var TD2 = document.createElement('td');
          var TD3 = document.createElement('td');
          TD1.innerHTML = value;
          TD2.innerHTML = "<input type='text' id='test1' value=''>";
          TD3.innerHTML = "<input type='text' id='test2' value=''>";
          TR.appendChild (TD1);
          TR.appendChild (TD2);
          TR.appendChild (TD3);
          BODY.appendChild(TR);
        }

        function addData(num,num1)
        {
          alert("Showing assignment of values");
          document.getElementById("test1").value=num;
          document.getElementById("test2").value=num1;
        }
      </script>
    </head>
  <body>

  <table id="tableId" border='1' cellspacing='0' cellpadding='0'>
  <tr>
    <td>Variable</td> 
    <td>Value1</td>
    <td>Value2</td>
  </tr>
  <button type="button" onclick="start()">Display</button>                  
  </table>

</body>

please suggest how to iterate through the text boxes created in 2nd and 3rd column

  • 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-16T00:19:09+00:00Added an answer on June 16, 2026 at 12:19 am

    I modified your addrow and addData functions

    For addrow function
    You have to use the value inside test1 and test2 to form the input ids
    like this

    TD2.innerHTML ="<input type='text' id='"+ test1 + "' value=''>";
    TD3.innerHTML ="<input type='text' id='"+ test2 + "' value=''>";
    

    for addData function bring in the ‘value’ variable as a parameter
    and change the document.getElementById statements as

    document.getElementById(value + "1").value=num;
    document.getElementById(value + "2").value=num1;
    

    Please check jsFiddle http://jsfiddle.net/TbGcD/1/

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

Sidebar

Related Questions

I am trying to iterate through an NSArray with a for loop. The result
I am trying to iterate through a list, and I need to perform specific
I am trying to iterate through a list checking every string in the list
I am trying to loop through an integer array using C# Iterators. The program
ive been trying to use node.js to iterate through an array of cities and
I'm trying to make a loop that will recurse through an array of bytes
I am trying to loop through the list items of several ULs of a
So I'm trying to loop through all the values of tables, which connect by
I have a for loop which iterates through a text file (in this case
I'm trying to iterate through a loop on one thread, like so: for (UnitTask

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.