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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:41:41+00:00 2026-05-21T07:41:41+00:00

Hello I a very new to Javascript and I need to make a code

  • 0

Hello I a very new to Javascript and I need to make a code that allows someone to enter a date and it will result in the season that date is in. I am at a loss at what I should do, an if else statement? This is as far as I got, thank you for everyone’s time!

<body>
<h1>Date to Season</h1>
<p align="left">Enter Date:
<input id="season" maxlength="4" size="24"/>
</p>
<input type="button" value="Submit" onclick="Submit()"/><br/>
<textarea cols="40" rows="3" id="output"></textarea></body>

<script type="text/javascript">
function Submit(){
var date = document.getElementById('season').value;
var seasons = 

if (
  • 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-21T07:41:41+00:00Added an answer on May 21, 2026 at 7:41 am

    Note, there are saner ways of doing this (for instance, using a date object for instance), that would probably be more useful/flexible, especially if you want to determine by the actual season start/stop date (March 28th, for example). This is just to demonstrate a starting point.

    Here’s a very simple example, using a swtich() to return a season according to a numeric month:

    http://jsfiddle.net/RtC58/

    <form name="date">
     <input type="text" name="month"/>
     <input type="button" value="Season?" onClick="getSeason()"/>
    </form>
    
    function getSeason() {
        month = document.forms.date.month.value;
        season = '';
        switch(month) {
            case '12':
            case '1':
            case '2':
                season = 'winter';
            break;
            case '3':
            case '4':
            case '5':
                season = 'spring';
            break;
            case '6':
            case '7':
            case '8':
                season = 'summer';
            break;
            case '9':
            case '10': 
            case '11':
                season = 'fall';
            break;
        }
        alert(season);
    }
    

    Here’s a little bit more complex example, showing the short/long month plus the numeric month.

    http://jsfiddle.net/RtC58/1/

    function getSeason() {
        month = document.forms.date.month.value.toLowerCase();
        season = 'unknown';
        switch(month) {
            case 'dec':
            case 'december':
            case '12':
            case 'jan':
            case 'january':
            case '1':
            case 'feb':
            case 'february':
            case '2':
                season = 'winter';
            break;
            case 'mar':
            case 'march':
            case '3':
            case 'apr':
            case 'april':
            case '4':
            case 'may':
            case '5':
                season = 'spring';
            break;
            case 'jun':
            case 'june':
            case '6':
            case 'jul':
            case 'july':
            case '7':
            case 'aug':
            case 'august':
            case '8':
                season = 'summer';
            break;
            case 'sep':
            case 'september':
            case '9':
            case 'oct':
            case 'october':
            case '10':
            case 'nov':
            case 'november':
            case '11':
                season = 'fall';
            break;
        }
        alert(season);
    }
    

    A little bit different approach could be to create variables for the seasons, use if/else statements (as the OP wants an example of) and find the ‘index of’ the month value in the one of the variables (note I added a , [comma] to the end of the month to disambiguate 1 from 12 and 1 from 0, etc…).

    http://jsfiddle.net/RtC58/3/

    function getSeason() {
        month = document.forms.date.month.value.toLowerCase()+",";
        winter = 'dec,december,jan,january,feb,february,12,1,2,';
        spring = 'mar,march,apr,april,may,3,4,5,';
        summer = 'jun,june,jul,july,aug,august,6,7,8,';
        fall = 'sep,september,oct,october,nov,november,9,10,11,';
        season = 'unknown';
        if (winter.indexOf(month) != -1) {
            season = 'winter';
        } else if (spring.indexOf(month) != -1) {
            season = 'spring';
        } else if (summer.indexOf(month) != -1) {
            season = 'summer';
        } else if (fall.indexOf(month) != -1) {
            season = 'fall';
        }
        alert(season);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello im very new at AS3 so im a litle confused trying to get
Hello Friends I am a newbie programmer and very very new to PHP. I
Hello fellow stackoverflow members! I'm very new to the C# language transfer from Java,
I am very new to Android application development. Just started Hello world android application
Edited 3.9.2011 to add one more related question Hello, I'm very new to WCF
I am very new to ruby / rails and have an issue that I
I just installed Ubuntu 8.04 and Eclipse. I made a very simple Hello World
Hello I am compiling a program with make but I get the error of
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello there and Merry Christmas !!! I am new to WPF and I am

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.