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

  • Home
  • SEARCH
  • 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 9038487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:30:02+00:00 2026-06-16T09:30:02+00:00

I want to populate a drop down list with a set of values, from

  • 0

I want to populate a drop down list with a set of values, from 1,2,…. 100. Currently, I am doing this and its not working.

In the head section

<script type="text/javascript" src="./jquery-1.8.3.min.js"></script>
<script type="text/javascript">
    var select = document.getElementById("selectAge");
    var options = ["1", "2", "3", "4", "5"];
    for(var i = 0; i < options.length; i++) {
        var opt = options[i];
        var el = document.createElement("option");
        el.textContent = opt;
        el.value = opt;
        select.appendChild(el);
    }​
</script>

And, then in the form, I have

<label>Age</label>
<select id="selectAge"> 
    <option>Select your age</option>        
</select>

The drop down is not populated with a single value. I mean, I don’t understand why its not happening. One correction might be to put the java script code just before the closing </body> tag, as its supposed to be populated only after the DOM is loaded. But I have even tried that and it does not work.

  • 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-16T09:30:03+00:00Added an answer on June 16, 2026 at 9:30 am
    <html>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var selectAge = $("#selectAge"), 
            options = [1,2,3,4,5,6], 
            i;
            for ( i = 0; i < options.length; i++) {
                $(selectAge).append("<option value='" + options[i] + "'>" + options[i] + "</option>");
            }
        });
    </script>
    <body>
    <lable>Age:</lable>
    <select id="selectAge">
        <option>Select your age</option>
    </select>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to populate a drop down list with values from database. <?php require
I want to populate a drop down menu with a column from a MySQL
I have this to populate a drop down list in an ASP.NET MVC view.
I want to populate one drop down list based on the selection of another
Basically I have a drop down list which is populated with text and values
Possible Duplicate: JavaScript - populate drop down list with array I have following select
I'm creating a SelectList to populate a dropdown list from a LINQ query. This
I want to add a Select One option to a drop down list bound
Want to populate dynamically combobox-listbox-drop-down using javascript. var table = document.createElement(table); var select =
I want to populate a select list such that it increments for each 5

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.