Need help with dynamic variables
Posted: Wed Jan 29, 2003 4:54 pm
I have a form for a user to enter event information. The form requests 3 separate dates (event start date, event end date and broadcast date). I call a function to display separate drop down lists for month/day/year on the form.
I use the form in multiple instances (create, edit, copy an event), and in many cases, the start and end dates are the same day, while the broadcast date is always in the future.
I would like to call the function with the same variables in all 3 places on the form, (i.e., displayDateDropdown ($$Title,$$Month,$$Day,$$Year), instead of displayDateDropdown("start_",$start_dateMO ,$start_dateDAY,$start_dateYR), etc.), but I can't quite get my hands around the dynamic variables.
Any help would be appreciated, Ruth
Code: Select all
function displayDateDropdown($Title,$Month,$Day,$Year)
{
//Create an array of months
$monthName = array (1=> "January", "February", "March", etc.
// Build selection list for the month
echo "<select name='".$Title."_dateMO'>\n";
$SelectMonthї$Month]=" selected";
for ($n=1; $n<=12; $n++) {
echo "<option value=$n".$SelectMonthї$n].">$monthNameї$n]</option>\n";
}
echo "</SELECT>\n";
etc..Code: Select all
$today = Time();
$start_dateMO = date("n", $today); //current month
$start_dateDAY = date("j", $today); //current day
$start_dateYR = date("Y", $today); //current year
$end_dateMO = date("n", $today); //same month
$end_dateDAY = date("j", $today); //same day
$end_dateYR = date("Y", $today); //same year
$broadcast_dateMO = 2; //later date
$broadcast_dateDAY = 10;
$broadcast_dateYR = 2003;I would like to call the function with the same variables in all 3 places on the form, (i.e., displayDateDropdown ($$Title,$$Month,$$Day,$$Year), instead of displayDateDropdown("start_",$start_dateMO ,$start_dateDAY,$start_dateYR), etc.), but I can't quite get my hands around the dynamic variables.
Any help would be appreciated, Ruth