sticky date selection form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
marlos
Forum Newbie
Posts: 1
Joined: Thu Dec 17, 2009 10:51 pm

sticky date selection form

Post by marlos »

Please fellows help me out! I have this departure date selection form and eg. today is 17 and i select 20. If i didn't fill in any required field before pressing send, the form will refer back to the form and all the other fields stays remembered but the departure field reselt to todays date. Please could anyone help so that it stays remembered like the other fields? That would be great! Hier are the codes:

Code: Select all

 
<?
Function ShowFromDate($year_interval,$YearIntervalType) {
//GLOBAL $day,$month,$year;
 
//DAY
echo "<select class='formDay' name='AbreisedatumD'>\n";
$i=1;
$date = strtotime("+1 day");
$CurrDay=date("d", $date);
If(!IsSet($day)) $day=$CurrDay;
while ($i <= 31)
      {
       If(IsSet($day)) {
         If($day == $i || ($i == substr($day,1,1) && (substr($day,0,1) == 0))) {
                  echo"<option selected> $day\n";
                  $i++;
         }Else{
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo "<option> $i\n";
                }
                $i++;
         }
       }Else {
              If($i == $CurrDay)
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo"<option> $i\n";
                }
              Else {
                If($i<10) {
                   echo "<option> 0$i\n";
                }Else {
                   echo "<option> $i\n";
                }
              }
              $i++;
       }
      }
echo "</select>\n";
 
//MONTH
echo "<select class='formMonth' name='AbreisedatumM'>\n";
$i=1;
$CurrMonth=date("m");
while ($i <= 12)
     {
      If(IsSet($month)) {
         If($month == $i || ($i == substr($month,1,1) && (substr($month,0,1) == 0))) {
            echo"<option selected> $month\n";
            $i++;
         }Else{
            If($i<10) {
               echo "<option> 0$i\n";
            }Else {
               echo "<option> $i\n";
            }
            $i++;
         }
      }Else {
            If($i == $CurrMonth) {
              If($i<10) {
                 echo "<option selected> 0$i\n";
              }Else {
                 echo "<option selected> $i\n";
              }
            }Else {
              If($i<10){
                 echo "<option> 0$i\n";
              }Else {
                 echo "<option> $i\n";
              }
            }
            $i++;
      }
}
  echo "</select>\n";
 
//YEAR
  echo "<select class='formYear' name='AbreisedatumY'>\n";
  $CurrYear=date("Y");
  If($YearIntervalType == "Past") {
      $i=$CurrYear-$year_interval+1;
      while ($i <= $CurrYear)
           {
            If($i == $year) {
               echo "<option selected> $i\n";
            }ElseIf ($i == $CurrYear && !IsSet($year)) {
               echo "<option selected> $i\n";
            }Else {
               echo "<option> $i\n";
            }
            $i++;
           }
       echo "</select>\n";
  }
  If($YearIntervalType == "Future") {
      $i=$CurrYear+$year_interval;
      while ($CurrYear < $i)
           {
            if ($year == $CurrYear) echo "<option selected> $CurrYear\n";
              else echo "<option> $CurrYear\n";
            $CurrYear++;
           }
       echo "</select>\n";
  }
  If($YearIntervalType == "Both") {
      $i=$CurrYear-$year_interval+1;
      while ($i < $CurrYear+$year_interval)
           {
            if ($i == $CurrYear) echo "<option selected> $i\n";
              else echo "<option> $i\n";
            $i++;
           }
       echo "</select>\n";
  }
}
 
//Ussage Example :
ShowFromDate(4,"Future");
?>
 
Best regard
Last edited by Benjamin on Sat Dec 19, 2009 2:37 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: sticky date selection form

Post by AbraCadaver »

Holy carp! Edit your post and put the code in code tags and I may look at it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: sticky date selection form

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply