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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:43:15+00:00 2026-06-17T14:43:15+00:00

I’m sure this is really simple. But it just won’t work for me. I

  • 0

I’m sure this is really simple. But it just won’t work for me.

I wrote a form that allows the user to select a month from a list using the tags:

<select> <option>

onchange the class .gone from the day SELECT is removed, thereby displaying the list.
onchanve the class .gone from the year INPUT is removed, thereby displaying the year.

I used PHP to set the value for year to the current year. I want to take the value from month and addClass .gone to the OPTION tag of the 31st day (and 29 and 30 for february) so that February 30th etc. isn’t an option. I will % the value of year by 4==0 to check leap year and then not addClass .gone to the 29th of february. Basic date select form.

The Problem: When I add class .gone to OPTION it is still displayed. I assumed this is simply me forgetting some basic principle of html. Nevertheless, I can’t figure it out.

CSS:

.gone {display:none;}

I could also use this:

.hidden {visibility:hidden;}

but that still displays the space, so I didn’t use it.

HTML:

<html>
  <head>
     <link to css styles>

    <script language="JavaScript" type="text/javascript">
       function showDay() {

           $("#day").removeClass("gone")
       }

       function showYear() {

           $("#year").removeClass("gone")
       }
    </script>


  </head>
  <body>
      <table>
         <tr>
         <td>
           <select id="month" onchange="showDay();">
              <option>January</option>
              <option>more months...yada...yada</option>
              <option>December</option>
           </select>
         </td>
         <td>
           <select class="gone" id="day" onchange="showYear();">
              <option></option>
              <option>1</option>
              <option>2</option>
              <option>more days</option>
              <option class="gone">31</option>
           </select>
         </td>
         <td>
              <input class="gone" type="text"  size="5" name="year" id="year" 
               value="<?php echo date("Y"); ?>"/>
         </td>
         </tr>
      </table>
  </body>
</html>

The onchange javascript and php work exactly how I want them too. I didn’t bother writing any scripts to make the days appear or disappear yet because simply putting the .gone class in the OPTION tag didn’t work. Is there a way to make it hidden or not selectable? Once I figure that out, I’ll write the script to make it happen based on the month and year.

Thank you for all the help!

UPDATE!!!

Based on the answers received. I am going to disable the dates that I don’t want selectable using javascript. From w3schools.com I got a sample script, which I modified slightly, and set to call onchange from the month SELECT.

function disableElement()
{
  var sel=document.getElementById("day")
  sel.options[30].disabled=true;
  sel.options[31].disabled=true;
}

It worked perfectly. Now the 30th and 31st day are not selectable!

  • 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-17T14:43:16+00:00Added an answer on June 17, 2026 at 2:43 pm

    The Problem: When I add class .gone to OPTION. it is still displayed. I assumed this is simply me forgetting some basic principle of html. Nevertheless, I can’t figure it out.

    Nope, <option>s just don’t support styling via CSS. Either disabled it, or remove it from the DOM entirely.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.