Gossamer Forum
Home : Products : DBMan : Customization :

Print next year in date field

Quote Reply
Print next year in date field
Hi,
One of my db 'select fields' is 'year'. but i want to propose only to choose this year and the year after, no more.
This would avoid me to correct each year the 'select field' with '2003,2004', then '2004,2005'.
Do you know if there's a way to do that ?
Quote Reply
Re: [jigme] Print next year in date field In reply to
Assuming you are using a 'date' field such as this in default.cfg

Date => [4, 'date', 12, 15, 1, &get_date, ''],


Then in html.pl you could have something like:

<input type="hidden" name="Date" value="$rec{'Date'}">
<select name="year">
|;
if ($rec{'Date'} =~ /2004/) {print qq|<option value="2004">2004</option><option value="2005">2005</option>|;}
if ($rec{'Date'} =~ /2005/) {print qq|<option value="2005">2005</option><option value="2006">2006</option>|;}
if ($rec{'Date'} =~ /2006/) {print qq|<option value="2006">2006</option><option value="2007">2007</option>|;}
print qq|
</select>

Not a good way to do it, but it'll work when adding a record, not sure about modifying though. Check out LoisC's unofficial FAQ at www.redundantcartridge.com/dbman for more help with dates.

.