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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:59:52+00:00 2026-05-27T07:59:52+00:00

Here’s what I have tried, which doesn’t work: <select name=mois id=mois> <option value= selected=selected>…</option>

  • 0

Here’s what I have tried, which doesn’t work:

<select name="mois" id="mois">
    <option value="" selected="selected">...</option>
    <script type="text/javascript">
    <!--//
    var d=new Date();
    var month=new Array(12);
    month[0]="Janvier";
    month[1]="Février";
    month[2]="Mars";
    month[3]="Avril";
    month[4]="Mai";
    month[5]="Juin";
    month[6]="Juillet";
    month[7]="Aout";
    month[8]="Septembre";
    month[9]="Octobre";
    month[10]="Novembre";
    month[11]="Décembre";
    document.write('<option value="'+(d.getMonth()+1)+'">'+month[d.getMonth()]+'</option>');
    //-->
    </script>
</select>
  • 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-27T07:59:53+00:00Added an answer on May 27, 2026 at 7:59 am
    1. Don’t use document.write
    2. Don’t “hide” your JavaScript with HTML comments.
    3. Use an array literal instead of new Array(12):

       var months = [
          'Janvier', 'Février', 'Mars', 'Avril',
          'Mai', 'Juin', 'Juillet', 'Aout',
          'Septembre', 'Octobre', 'Novembre', 'Décembre'
       ];
      
    4. Make sure, when checking d.getMonth, that you loop back to the beginning if the current month is the last month of the year (like it is right now):

       var d = new Date(),
          lastMonth = months.length - 1,
          thisMonth = d.getMonth(),
          nextMonth = thisMonth === lastMonth ? 0 : thisMonth + 1;
      
    5. Once you know the index of next month, you get to choose how to build the new <option> element and add it to the dropdown:

      • Use the createElement and appendChild DOM methods.

        var opt = document.createElement('option'),
           optTxt = document.createTextNode(months[nextMonth]);
        opt.appendChild(optTxt);
        document.getElementById('mois').appendChild(opt);
        
      • Just use innerHTML to do the same thing. A little easier for the developer, but innerHTML might not work on Mobile Safari. Also, if you have event listeners or any other JS stuff going on with the other options in your dropdown, those will be lost.

        document.getElementById('mois').innerHTML +=
           '<option>' + months[nextMonth] + '</option>';
        
      • Use insertAdjacentHTML to get the ease of innerHTML, but without having to discard and rebuild the dropdown’s entire DOM. (However, you’ll need a shim to make insertAdjacentHTML work with older versions of Firefox.)

        document.getElementById('mois').insertAdjacentHTML('beforeend',
           '<option>' + months[nextMonth] + '</option>');
        
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example: I have a file 1.js, which has some functions. I
I have just tried to save a simple *.rtf file with some websites and
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is an example: I have the generic type called Account. I wish to
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here is my SQL: SELECT COUNT(id), CONCAT(YEAR(created_at), '-', MONTH(created_at), '-', DAY(created_at)) FROM my_table GROUP
Here I have an int x=3; NSLog(@%i, x); How to have it displayed like
Here's my code. It tries to load Leaflet library. When I turn crossDomain option

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.