Solved

remove selectbox options depending on current date

Posted on 2007-03-29
4
167 Views
Last Modified: 2008-03-06
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??
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18814997
can you show your loop that fills the selectbox right now?

in php, you have extensive functions to get date information:
http://php.net/datetime

so:
$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>";
   $week++;
}

0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815019
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...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815032
BTW my loop is like this at the moment:

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



0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815091
thank you - got it working now
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question