Hello all,

So, I had this idea today. I want items in a drop down menu to be hidden after a specific date. I am totally lost on how to do this. here is what I have so far... (not much)

<select name="myList">
<!-- The id is the date it should expire -->
<option value="1" id="1-20-2010">Option 1</option>
<option value="2" id="1-23-2010">Option 2</option>
<option value="3" id="1-28-2010">Option 3</option>

I am a bit of a n00b at JS... Any help is greatly appreciated!


8 Years
Discussion Span
Last Post by almostbob
<select name="myList">
<script type='text/javascript'>
var today=new Date();
var mydate=new Date();
if ( today < mydate.setFullYear(2010,0,14)) { document.write("<option value='1' id='1-20-2010'>Option 1</option>"); }
if ( today < mydate.setFullYear(2010,0,23)) { document.write("<option value='2' id='1-23-2010'>Option 2</option>"); }
if ( today < mydate.setFullYear(2010,0,28)) { document.write("<option value='3' id='1-28-2010'>Option 3</option>"); }

code explanation, compare todays date with the expirydate Year month(zero based Jan) day, and write the option if it hasnt arrived yet
If the date range should include the expiry date than change < (less than) to <= (less than eq)

code may not function on user browsers with javascript disabled
Serverside, in php asp, is a better approach, a very similar script, for 'must work' functions

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.