PDA

View Full Version : Dynamic Listing dropdown


bangonthedrum
12-18-2005, 04:51 PM
Hey, I created a dynamic form to display on your page to use the List module to have an easy archive of years:
(i tried making this code generic, hopefully i didn't mess it up in the process..also, this is for version 5.7)


<?php
$nextyear = date("Y")+1;
//show curent year when landing on page
if(!$_POST["posted"]){
$thedate = date("Y");
$LIST=1;
$listYear = $thedate;
$DF = "m/d/y";
$template="templatefile.php";
//Show Form 1 before selecting
print '<div align="right">';
print '<form name="dates" method="post" action="thepagethathasthiscode.php">';
printf("Archive:&nbsp;<select name=\"calyear\">");
printf("<option value=\"\">%s</option>", 'Year');
for($i = $nextyear; $i > 2000; $i--){
$selected = $_POST["calyear"];
printf("<option value=\"%s\" %s>%s</option>", $i, $selected, $i);
}
printf("</select>");
print '<input type="hidden" name="posted" value="1"/>';
print '&nbsp;&nbsp;<input style="background-color:#ffffff" type="submit" value="submit" name="submitme" />';
print '</form>';
print '</div>';
require ("escal/showCalendar.php");
}
if($_POST["posted"]){
//show form 2 after selecting
print '<form name="dates" method="post" action="thepagethathasthiscode.php">';
print '<div align="right">';
printf("Archive:&nbsp;<select name=\"calyear\">");
printf("<option value=\"\">%s</option>", $_POST["calyear"]);
for($i = $nextyear; $i > 2000; $i--){
$selected = $_POST["calyear"];
printf("<option value=\"%s\" %s>%s</option>", $i, $selected, $i);

}
printf("</select>");
print '<input type="hidden" name="posted" value="1"/>';
print '&nbsp;&nbsp;<input style="background-color:#ffffff" type="submit" value="submit" name="submitme" />';
print '</form>';
print '</div>';
$thedate = $_POST["calyear"];
$LIST=1;
$listYear = $thedate;
$DF = "m/d/y";
$template="templatefile.php";
require ("escal/showCalendar.php");
}

?>