Page 1 of 1

sticky date selection form

Posted: Thu Dec 17, 2009 11:25 pm
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

Re: sticky date selection form

Posted: Fri Dec 18, 2009 9:46 am
by AbraCadaver
Holy carp! Edit your post and put the code in code tags and I may look at it.

Re: sticky date selection form

Posted: Sat Dec 19, 2009 2:38 pm
by Benjamin
:arrow: Moved to PHP - Code