the function below makes creates the select boxes I require to input a date.
but al my other select boxes have a different background colour to the plain one. Im not sure how to add a background colour to the select boxes through this function.
Code: Select all
/*** Function: DateSelector**
Input: STRING inName, INTEGER useDate** Output: **
Description: Creates three form fields for get month/day/year*/ function
DateSelector($inName, $useDate)
{ $monthName = array(1=>"January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December");
if($useDate == "")
{
$useDate = time();
}
print("<SELECT NAME=\"" . $inName . "Month\">\n");
for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
{
echo "<OPTION VALUE=\"";
echo intval($currentMonth);
echo "\"";
if(intval(date("m", $useDate))==$currentMonth)
{
echo " SELECTED";
}
echo ">".$monthName[$currentMonth]."\n";
}
echo "</SELECT>";
echo "<SELECT NAME=".$inName."Day>\n";
for($currentDay=1; $currentDay <= 31; $currentDay++)
{
echo "<OPTION VALUE=\"$currentDay\"";
if(intval(date("d", $useDate))==$currentDay)
{
echo " SELECTED";
}
echo ">$currentDay\n";
}
echo "</SELECT>";
echo "<SELECT NAME=".$inName."Year>\n";
$startYear = date("Y", $useDate);
if($startYear < 1997)
{
$startYear = date("Y");
}
for($currentYear = $startYear-1; $currentYear <= $startYear+2;$currentYear++) {
echo "<OPTION VALUE=\"$currentYear\"";
if(date("Y", $useDate)==$currentYear)
{
echo " SELECTED";
}
echo ">$currentYear\n";
} echo "</SELECT>";}
?>