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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:28:10+00:00 2026-06-12T13:28:10+00:00

I am trying to use a for loop in html but i dont even

  • 0

I am trying to use a for loop in html but i dont even know if this is possible. Is it? and if yes how? I dont want to use php. only html and javascript.

this is my goal: i have a file containing .txt files. i want to count the number of txt files and when i get the number i want to send it to where i will use a for loop to put the txt file’s numbers in a dropbox.

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-12T13:28:12+00:00Added an answer on June 12, 2026 at 1:28 pm

    Lots of answers…. here is another approach NOT using document.write OR innerHTML OR jQuery….

    HTML

    <select id="foo"></select>
    

    JS

    (function() { // don't leak
        var elm = document.getElementById('foo'), // get the select
            df = document.createDocumentFragment(); // create a document fragment to hold the options while we create them
        for (var i = 1; i <= 42; i++) { // loop, i like 42.
            var option = document.createElement('option'); // create the option element
            option.value = i; // set the value property
            option.appendChild(document.createTextNode("option #" + i)); // set the textContent in a safe way.
            df.appendChild(option); // append the option to the document fragment
        }
        elm.appendChild(df); // append the document fragment to the DOM. this is the better way rather than setting innerHTML a bunch of times (or even once with a long string)
    }());
    

    And here is a Fiddle to demo it.

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

Sidebar

Related Questions

I'm trying to use the foreach loop in an Ant script but I get
I'm trying to use a cursor loop in MYSQL, but it's not working. I've
I'm a beginner to Python trying to decode this javascript sequence. I'm not only
I'm trying to use the Html.DropDownList extension method but can't figure out how to
I am trying to use for..in loop to access the description key/value within 'Event'
I'm trying to use Linq to loop through all fonts in the %windir%\Fonts folder
I'm trying to use a foreach loop for an array of objects. Inside of
I am trying to use a for-if loop to run through a few CheckBoxList
I'm trying to use openmp to multithread a loop through std::set. When I write
I'm trying to use a for line in data: loop to assign the first

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.