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

The Archive Base Latest Questions

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

I’m delevoling an app with phonegap for android and I’m trying to make a

  • 0

I’m delevoling an app with phonegap for android and I’m trying to make a FOR loop in javascript with html table rows. I tried using the document.write but all of the content in the page desapears, show just what it’s in the document.write.
The code I have is this one:

<table id="hor-minimalist-b">
<script language=javascript>
for (var i=0; i<3; i++) {
    document.write('<tr>');
        document.write('<td>');
        document.write('<input type="text" name="valor" id="valor" value="key' + i'">');
        document.write('</td>');
        document.write('</tr>');
}
</script>
</table>

Thanks.

  • 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-11T13:04:27+00:00Added an answer on June 11, 2026 at 1:04 pm

    It’s because you are just putting text in the page, you need to “create” the element and append them to the table.
    You can do it this way:

    <table id="hor-minimalist-b"><thead></thead><tbody></tbody></table>
    <script language="javascript">
    var table = document.getElementById('hor-minimalist-b'); // get the table element
    var tableBody = table.childNodes[1]; // get the table body
    var tableHead = table.childNodes[0]; // get the table head
    for (var i=0; i<3; i++) {
        var row = document.createElement('tr'); // create a new row
        var cell = document.createElement('td'); // create a new cell
        var input = document.createElement('input'); // create a new input
        // Set input properties
        input.type = "text";
        input.id = "valor"; // It's not a good idea (to have elements with the same id..)
        input.name = "valor";
        input.value = "key" + i;
        cell.appendChild(input); // append input to the new cell
        row.appendChild(cell); // append the new cell to the new row
        tableBody.appendChild(row); // append the row to table body
    }
    </script>
    

    insertRow() and insertCell() will probably work too, but I did not test it yet

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to loop through a bunch of documents I have to put
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.