Connecting Tech Pros Worldwide Help | Site Map

select data in drop-down box

  #1  
Old October 19th, 2006, 03:15 AM
kirke
Guest
 
Posts: n/a
I have a two text box and one select box.

two text box will be filled with date values. (in the form of
dd-mm-year)
First text box is called "start date"
Second is "end date"

Thus, I want to put dates between "start date" and "end date" in select
box.

Is there any way to put automatically in option field?
My idea is, first calculate the date difference
and then, add date till startdate + difference.
Thx.

  #2  
Old October 19th, 2006, 04:35 AM
Rik
Guest
 
Posts: n/a

re: select data in drop-down box


kirke wrote:
Quote:
I have a two text box and one select box.
>
two text box will be filled with date values. (in the form of
dd-mm-year)
First text box is called "start date"
Second is "end date"
>
Thus, I want to put dates between "start date" and "end date" in
select box.
>
Is there any way to put automatically in option field?
My idea is, first calculate the date difference
and then, add date till startdate + difference.
It is possible with PHP when that 'start' date and the 'end' date are known
BEFORE the user requests that page. Simply generate all possible dates
between those two values, and commit them to select boxes. If they're not
known, or they cross month or year barriers, you'll have to rely on
javascript to limit the options (and make unlimited options available
without javascript, on a date outside the possibilities you will produce an
error on submitting).

Ofcourse, on submitting, whether javascript is enabled or not, you'll
always have to check start, interim, and end date on submitting to make
sure it's valid.

On HOW to make a date confirm by js, I'd suggest a trip to
comp.lang.javascript.

--
Grtz,

Rik Wasmus


  #3  
Old October 19th, 2006, 05:05 AM
kirke
Guest
 
Posts: n/a

re: select data in drop-down box


assume that I know the start and end date already.
Then How can I generate dates between two dates?


Rik wrote:
Quote:
kirke wrote:
Quote:
I have a two text box and one select box.

two text box will be filled with date values. (in the form of
dd-mm-year)
First text box is called "start date"
Second is "end date"

Thus, I want to put dates between "start date" and "end date" in
select box.

Is there any way to put automatically in option field?
My idea is, first calculate the date difference
and then, add date till startdate + difference.
>
It is possible with PHP when that 'start' date and the 'end' date are known
BEFORE the user requests that page. Simply generate all possible dates
between those two values, and commit them to select boxes. If they're not
known, or they cross month or year barriers, you'll have to rely on
javascript to limit the options (and make unlimited options available
without javascript, on a date outside the possibilities you will produce an
error on submitting).
>
Ofcourse, on submitting, whether javascript is enabled or not, you'll
always have to check start, interim, and end date on submitting to make
sure it's valid.
>
On HOW to make a date confirm by js, I'd suggest a trip to
comp.lang.javascript.
>
--
Grtz,
>
Rik Wasmus
  #4  
Old October 19th, 2006, 07:35 AM
Rik
Guest
 
Posts: n/a

re: select data in drop-down box


kirke wrote:
Quote:
assume that I know the start and end date already.
Then How can I generate dates between two dates?

Well, that should be easy, whipped together something for you (untested):

/* $start & $end = UNIX timestamps
$step = number of second between steps (60*60*24 for dates offcourse)
$format = returned format as in strftime()
$include_limits = boolean wether the start and end dates should be
included */

function generate_dates($start,$end,$step = 86400,$format =
'',$include_limits = false){
$start_i = intval($start);
$end_i = intval($end);
if($start_i!=$start || $end_i != $end){
trigger_error('No valid timestamps given.');
return false;
}
if($start_i $end_i){
trigger_error('Start date is later then End date.');
return false;
}
if(!is_int($step) || $step <= 0){
trigger_error('Step is either not an integer or zero or less.');
return false;
}
$return = array();
if($include_limits({
$return[] = $start;
}
$current = $start_i + $step;
while($current < $end_i){
$return[] = strftime($format,$current);
$current = ($current + $step);
}
if(end($return) < $end_i){
$return[] = $end;
}
return $return;
}

--
Rik Wasmus


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I combine three columns into one drop box in order to perform a search? stateemk answers 36 August 11th, 2009 06:13 PM
problem when editing the data in the ms access table ammoos answers 1 June 19th, 2008 08:46 AM
Access databases can not be used in VS 2005 =?Utf-8?B?RnJpdHo=?= answers 9 September 11th, 2007 11:15 PM
drop box doesnt ad new record? Xiphias answers 5 November 12th, 2005 06:58 PM
How to response immediately when i select the drop-box list Krista answers 3 July 17th, 2005 03:22 AM