[OT] New element for CGI.pm (or StickyForms, etc.) (revised)

2000-07-18 Thread Kenneth Lee

Better still,

  print date_field(
-name ="expiry", 
-value="2000-12-25");

so that if value is omitted, the current value will be used.
But date format will be a great concern.

And how about time_field() also?

Sorry for the annoyance.


 Original Message 
Subject: [OT] New element for CGI.pm (or StickyForms, etc.)
Date: Tue, 18 Jul 2000 17:45:21 +0800
From: Kenneth Lee [EMAIL PROTECTED]
To: "[EMAIL PROTECTED]" [EMAIL PROTECTED]

Hi all,

anyone thought of a 'date_field' element for CGI.pm (or StickyForms, etc.)?

this is my thought,

  use CGI qw/:standard/;
  print date_field(
-name ="expiry", 
-year =2000, 
-month=12, 
-day  =25);
  $expiry_date = param('expiry');

which is an elegant way to do

  use CGI qw/:standard/;
  print textfield(-name='expiry_year', -value=2000);
  print popup_menu(-name='expiry_month', -values=[1..12], -default=12);
  print popup_menu(-name='expiry_day', -values=[1..31], -default=25);
  $expiry_date = sprintf "%d-%d-%d", param('expiry_year'), 
  param('expiry_month'), param('expiry_day');

and the date validation can be done in query string parsing too.

Thanks for any input.
Kenneth



Re: [OT] New element for CGI.pm (or StickyForms, etc.) (revised)

2000-07-18 Thread Ian Struble

I think that both the date_field and the time_field idea are good ones 
but how are you going to localize them?  The different formats for date 
and time might be a bit of a hassle.  But you might be able to have 
date_field return an array of 3 fields as is done with the check box 
constructor.  So you could use it like this and then arrange the date 
components however you want it:

  my ($year, $month, $day) = date_field(-name ="end_date",
-value="2000-12-31")

  # I'm a farmer and I care most about the month...
  print "$month $day $yearbr\n";


Ian

On Tue, 18 Jul 2000, Kenneth Lee wrote:

 Better still,
 
   print date_field(
 -name ="expiry", 
 -value="2000-12-25");
 
 so that if value is omitted, the current value will be used.
 But date format will be a great concern.
 
 And how about time_field() also?
 
 Sorry for the annoyance.
 
 
  Original Message 
 Subject: [OT] New element for CGI.pm (or StickyForms, etc.)
 Date: Tue, 18 Jul 2000 17:45:21 +0800
 From: Kenneth Lee [EMAIL PROTECTED]
 To: "[EMAIL PROTECTED]" [EMAIL PROTECTED]
 
 Hi all,
 
 anyone thought of a 'date_field' element for CGI.pm (or StickyForms, etc.)?
 
 this is my thought,
 
   use CGI qw/:standard/;
   print date_field(
 -name ="expiry", 
 -year =2000, 
 -month=12, 
 -day  =25);
   $expiry_date = param('expiry');
 
 which is an elegant way to do
 
   use CGI qw/:standard/;
   print textfield(-name='expiry_year', -value=2000);
   print popup_menu(-name='expiry_month', -values=[1..12], -default=12);
   print popup_menu(-name='expiry_day', -values=[1..31], -default=25);
   $expiry_date = sprintf "%d-%d-%d", param('expiry_year'), 
   param('expiry_month'), param('expiry_day');
 
 and the date validation can be done in query string parsing too.
 
 Thanks for any input.
 Kenneth