lvalverdeb
Posts: 299
|
Posted: 09/19/2005, 3:23 PM |
|
In multi language apps, here's the code I am currently using to populate a Select control with the appropriate Month Names ( mainly for search forms pulling data from a mysql database using month('date') as part of the query criteria).
function GetMonthList() {
global $Months; // defined in Common.php;
$MonthList = array();
foreach(array_keys($Months) as $EachMonth) {
array_push($MonthList,array($EachMonth+1,$Months[$EachMonth]));
}
return $MonthList;
}
In the BeforeShow event of the select control add the following code:
$form->selectControl->Values = GetMonthList();
Similar approach can be used for Weekdays:
function GetDayList() {
global $Weekdays; // defined in Common.php;
$DayList = array();
foreach(array_keys($Weekdays) as $EachDay) {
array_push($DayList,array($EachDay+1,$Weekdays[$EachDay]));
}
return $DayList;
}
Please note that I am using an increment of 1 for $EachMonth and $EachDay to make the result compatible with MySQL date calculations.
Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |