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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:29:10+00:00 2026-05-27T08:29:10+00:00

I need to have a drop-down menu that allows you to select a year

  • 0

I need to have a drop-down menu that allows you to select a year from it (1900-2011). I am pretty sure that java-script has the functionality for that but I am totally lost on how to do it in code.

I am using PHP.

Wouldn’t it be something along the lines of this?

while(i<2012){
add i to dropdown list
increment i
}

This is the current code I have for the form:

<form action="cite.php" method="post">
<h1>Newspaper</h1>

<script>

var select = document.getElementById("year");
for(var i = 2011; i >= 1900; --i) {
    var option = document.createElement('option');
    option.text = option.value = i;
    select.add(option, 0);
}


</script>

<table width="100%">
  <tr>
    <td><h3>Author Name</h3></td>
    <td><table width="100%" border="0">
      <tr>
        <td><label>
          <input type="text" name="lastName" id="lastName" />
        </label></td>
      </tr>
      <tr>
        <td><label>
          <input type="text" name="firstName" id="firstName" />
        </label></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><h3>Title of Article</h3></td>
    <td><label>
      <input type="text" name="artTit" id="artTit" />
    </label></td>
  </tr>
  <tr>
    <td><h3>Title of Newspaper</h3></td>
    <td><label>
      <input type="text" name="newsTit" id="newsTit" />
    </label></td>
  </tr>
  <tr>
    <td><h3>City</h3></td>
    <td><label>
      <input type="text" name="city" id="city" />
    </label></td>
  </tr>
  <tr>
    <td><h3>Date Published</h3></td>
    <td><table width="100%" border="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><select id="year" name="year"></select>
</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><h3>Edition</h3></td>
    <td><label>
      <input type="text" name="edi" id="edi" />
    </label></td>
  </tr>
  <tr>
    <td><h3>Page Designation</h3></td>
    <td><label>
      <input type="text" name="page" id="page" />
    </label></td>
  </tr>
  <tr>
    <td><h3>Medium</h3></td>
    <td><table width="200">
      <tr>
        <td><label>
          <input type="radio" name="RadioGroup1" value="print" id="RadioGroup1_0" />
          Print</label></td>
      </tr>
      <tr>
        <td><label>
          <input type="radio" name="RadioGroup1" value="web" id="RadioGroup1_1" />
          Web</label></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label>
      <input type="text" name="med" id="med" />
    </label></td>
  </tr>
  <tr>
    <td><input type="hidden" name="hiddenField" id="hiddenField" /></td>
    <td><label>
      <input type="submit" name="Submit" id="Submit" value="Submit" />
    </label></td>
  </tr>
</table>


</form>
  • 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-05-27T08:29:11+00:00Added an answer on May 27, 2026 at 8:29 am

    Assuming you have this element:

     <select id="year" name="year"></select>
    

    You can use this code:

    var select = document.getElementById("year");
    for(var i = 2011; i >= 1900; --i) {
        var option = document.createElement('option');
        option.text = option.value = i;
        select.add(option, 0);
    }
    

    See it in action.

    However: Why do you need to do this? Is it not possible to directly populate the drop down from the server side, which would be more natural?

    Update: From PHP:

    <td>
        <select id="year" name="year">
        <?php for($i = 2011; $i >= 1900; --$i) 
                  printf('<option value="%d">%d</option>', $i, $i);
        ?>
        </select> 
    </td> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make tabs that also have drop down menu and requirements are
I need to select an element from a drop-down menu. For example: <select id=fruits01
I have a range of items in an HTML drop-down menu that I need
I have a drop down list that has options that need to be passed
I have a drop down menu that looks like this: It works fine, but
I have this drop down menu that when one menu is clicked if there
My problem is: I have a drop down menu and i want that when
I have an existing drop down menu that I am attempting to convert to
I am trying to load a simple select drop down menu from a collection.
I have a drop-down menu that I would like to dynamically update using jQuery.

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.