• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

remove selectbox options depending on current date

ive got a selectbox with all the week numbers starting with week 1 and finishing with week 52.

what i need to do is remove all the week numbers after a certain date in each month.  The certain date is the 3rd of each month.

currently we are on week 13.  when it comes to april 3rd, all week numbers before this date should no longer be available to select.  when it comes to may 3rd, all week numbers before the may 3rd should no longer be available and so on...

my problem is, i have no idea where to start or code something that will do the above??
  • 3
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you show your loop that fills the selectbox right now?

in php, you have extensive functions to get date information:

$date = getdate();
$date2 = mktime(0,0,0, $date["mon"], 3, $date["year"] )
$week = date("W", $date2);

while ($week <= 53)
   echo "<option value=\"$week\">$week</option>";

ellandrdAuthor Commented:
ok what ive tried to do was this:

1) get todays date
2) loop from todays date to the 31/12/2007
3) create selectbox with all weeknumbers between these dates

but it didnt work too good.  i will take a look at what you suggested...
ellandrdAuthor Commented:
BTW my loop is like this at the moment:

for($wk = 1; $wk < 53; $wk++)
      <option value="'.$wk.'">'.$wk.'</option>

ellandrdAuthor Commented:
thank you - got it working now
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now