Page 1 of 1

[Solved]Keeping form values

Posted: Fri Sep 03, 2004 4:07 pm
by AlbinoJellyfish
With the page and the calendars, how would I keep the form data if you click a link on the calendar?


http://prototype.edienterprises.com/mat ... /form1.php

Posted: Fri Sep 03, 2004 4:10 pm
by AlbinoJellyfish
Heres the updated code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Prepaid Software</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Please enter all information.
<form name="form1" method="post" action="form2.php">
<table width="817" height="361" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="602"><p><strong>Platform:</strong></p>
      <p>GEM-Lightning.........................................................................<br>
      GEM-Thunder...........................................................................<br>
    PCMCIA (EDI Approved)............................................................</p></td>
    <td width="215">        <br>
        <br>
        <input name="platform" type="radio" value="lightning"><br>
        <input name="platform" type="radio" value="thunder"><br>
        <input name="platform" type="radio" value="pcmcia">
    </td>
  </tr>
  <tr>
    <td><strong>Serial Number: </strong>      <input name="serial" type="text" size="50"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><p><strong>Protocols:</strong></p>
      <p>
        <input name="r2" type="checkbox" id="r2" value="r2"> 
        R2
   			<input name="gr303" type="checkbox" id="gr303" value="gr303">
GR-303        
<input name="idsn" type="checkbox" id="idsn" value="idsn"> 
IDSN-PRI 
        <input name="v5" type="checkbox" id="v5" value="v5">
        V5        </p>
      <p>
    <input name="tr08" type="checkbox" id="tr08" value="tr08">
    TR08
    <input name="calea" type="checkbox" id="calea" value="calea">        
      CALEA          
          <input name="ss7" type="checkbox" id="ss7" value="ss7"> 
      SS7</p>      </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Start Date <?php

$FONT ="Verdana, Arial, Helvetica, sans-serif";
$FONTSIZE="8";
$FONTCOLOR="#000000";
$BorderColor="#CCCCFF";
$BarColor="#000066";

function WriteMonth($StartDate,$Border_color,$Title_color){
	$WriteMonth="";
	$CurrentDate=date("m/1/y", strtotime ("$StartDate"));
	$setMonth=date("m",strtotime ($CurrentDate));
	$BeginWeek=date("m",strtotime ($CurrentDate));
	$EndWeek=date("m",strtotime ($CurrentDate));
	
	$WriteMonth="
			<table border=0 cellspacing=0 cellpadding=0 bgcolor='$Border_color' width=150 resize=none >
			<tr><td>
			<table border=0 cellspacing=1 cellpadding=2 resize=none width='100%' style='border: 1pt solid $Border_color' >
			<tr>
				<td colspan=7 valign=top BGCOLOR='$Title_color' align=center >
				<a href='form1.php?GoToDay1="
				.date("m/1/y", strtotime ("$StartDate -1 months")).
				"&GoToDay2=".$_GET['GoToDay2']."'>
				<font color='white'><<<</font></a>
				<b><font color='white'>"
				.date("M",strtotime ($StartDate))." ".date("Y",strtotime ($StartDate)).
				"</font></b>
				<a href='form1.php?GoToDay1="
				.date("m/1/y", strtotime ("$StartDate +1 months")).
				"&GoToDay2=".$_GET['GoToDay2']."'><font color='white'>>>></font></a>
				</td>
			</tr>
			<tr>
				<td align='center' valign=top bgcolor=white ><B>S</B></td>
				<td align='center' bgcolor=white ><B>M</B></td>
				<td align='center' bgcolor=white ><B>T</B></td>
				<td align='center' bgcolor=white ><B>W</B></td>
				<td align='center' bgcolor=white ><B>T</B></td>
				<td align='center' bgcolor=white ><B>F</B></td>
				<td align='center' bgcolor=white ><B>S</B></td>
			</tr>
	";
	for($j=1;$j<6;$j++){
		if($BeginWeek==$setMonth||$EndWeek==$setMonth){	
			switch(date("w",strtotime($CurrentDate))){
			case 0:
				$DaysToAd=array("","+1 days","+2 days","+3 days","+4 days","+5 days","+6 days");
				break;
			case 1:
				$DaysToAd=array("-1 days","","+1 days","+2 days","+3 days","+4 days","+5 days");
				break;
			case 2:
				$DaysToAd=array("-2 days","-1 days","","+1 days","+2 days","+3 days","+4 days");
				break;
			case 3:
				$DaysToAd=array("-3 days","-2 days","-1 days","","+1 days","+2 days","+3 days");
				break;
			case 4:
				$DaysToAd=array("-4 days","-3 days","-2 days","-1 days","","+1 days","+2 days");
				break;
			case 5:
				$DaysToAd=array("-5 days","-4 days","-3 days","-2 days","-1 days","","+1 days");
				break;
			case 6:
				$DaysToAd=array("-6 days","-5 days","-4 days","-3 days","-2 days","-1 days","");
				break;
			}	
			$WriteMonth.="<tr>";
			for($i=0;$i<7;$i++){
				$strTemp="";
				$BGcolor="white";
				$FontColor="#000000";
				$Style="";
				if(date("m",strtotime ("$CurrentDate $DaysToAd[$i]"))!=$setMonth){
					$FontColor="#999999";
				}
				if(date("m/d/y",strtotime ("$CurrentDate $DaysToAd[$i]"))==
				date("m/d/y",strtotime($StartDate))){
					$Style="style='border: 1pt solid red'";
				}
				$WriteMonth.="
					<td align=center bgcolor='$BGcolor' $Style >
					<a href='form1.php?GoToDay1="
					.date("m/d/y",strtotime ("$CurrentDate $DaysToAd[$i]")).
					"&GoToDay2=".$_GET['GoToDay2']."'><font color='$FontColor'>"
					.date("d",strtotime ("$CurrentDate $DaysToAd[$i]")).
					"</font></a></td>";
			}
			$WriteMonth.="</tr>";
			$CurrentDate=date("m/d/y",strtotime("$CurrentDate +1 week"));
			$StartDateofWeek=date("w",strtotime ($CurrentDate));
			$EndofWeek=6 - $StartDateofWeek;
			$BeginWeek=date("m",strtotime ("$CurrentDate -$StartDateofWeek days"));
			$EndWeek=date("m",strtotime ("$CurrentDate +$EndofWeek days"));
		}
	}
	$WriteMonth.="</table></td></tr></table>";
	return $WriteMonth;
}
$GoToDay1 = $_GET['GoToDay1'];
if(!empty($GoToDay1)){
	$StartDate=date("m/d/y",strtotime ("$GoToDay1"));
}else{
	if(empty($StartDate)){
		$StartDate=date("m/d/y");
	}
}

print "<head>";
print "<style>";
print "A, TD, LI, P{font-family: $FONT;font-size: $FONTSIZE.pt;color: $FONTCOLOR;}
";
print "BODY{font-family: $FONT;font-size: $FONTSIZE.pt;}
";
print "</STYLE></head>";
print "<body>";
print "
	<table width='100%' >
		<tr>
		<td width='100'>"
		.WriteMonth($StartDate,$BorderColor,$BarColor,1).
		"</td>
		<td><font size=1>Today's Date: "
		.date("M d, Y").
		"</font><p><font siz2=4><b>Selected start date: "
		.date("M d, Y",strtotime($StartDate)).
		"</b></font></td>
		</tr>
	</table>
";
$date1 = date("M d, Y",strtotime($StartDate));
?>

</strong></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>End Date <?php

$FONTd ="Verdana, Arial, Helvetica, sans-serif";
$FONTSIZEd="8";
$FONTCOLORd="#000000";
$BorderColord="#CCCCFF";
$BarColord="#000066";

function WriteMonthd($StartDated,$Border_colord,$Title_colord){
	$WriteMonthd="";
	$CurrentDated=date("m/1/y", strtotime ("$StartDated"));
	$setMonthd=date("m",strtotime ($CurrentDated));
	$BeginWeekd=date("m",strtotime ($CurrentDated));
	$EndWeekd=date("m",strtotime ($CurrentDated));
	
	$WriteMonthd="
			<table border=0 cellspacing=0 cellpadding=0 bgcolor='$Border_colord' width=150 resize=none >
			<tr><td>
			<table border=0 cellspacing=1 cellpadding=2 resize=none width='100%' style='border: 1pt solid $Border_colord' >
			<tr>
				<td colspan=7 valign=top BGCOLOR='$Title_colord' align=center >
				<a href='form1.php?GoToDay1="
				.$_GET['GoToDay1']."&GoToDay2="
				.date("m/1/y", strtotime ("$StartDated -1 months")).
				"'>
				<font color='white'><<<</font></a>
				<b><font color='white'>"
				.date("M",strtotime ($StartDated))." ".date("Y",strtotime ($StartDated)).
				"</font></b>
				<a href='form1.php?GoToDay1="
				.$_GET['GoToDay1']."&GoToDay2="
				.date("m/1/y", strtotime ("$StartDated +1 months")).
				"'><font color='white'>>>></font></a>
				</td>
			</tr>
			<tr>
				<td align='center' valign=top bgcolor=white ><B>S</B></td>
				<td align='center' bgcolor=white ><B>M</B></td>
				<td align='center' bgcolor=white ><B>T</B></td>
				<td align='center' bgcolor=white ><B>W</B></td>
				<td align='center' bgcolor=white ><B>T</B></td>
				<td align='center' bgcolor=white ><B>F</B></td>
				<td align='center' bgcolor=white ><B>S</B></td>
			</tr>
	";
	for($jd=1;$jd<6;$jd++){
		if($BeginWeekd==$setMonthd||$EndWeekd==$setMonthd){	
			switch(date("w",strtotime($CurrentDated))){
			case 0:
				$DaysToAdd=array("","+1 days","+2 days","+3 days","+4 days","+5 days","+6 days");
				break;
			case 1:
				$DaysToAdd=array("-1 days","","+1 days","+2 days","+3 days","+4 days","+5 days");
				break;
			case 2:
				$DaysToAdd=array("-2 days","-1 days","","+1 days","+2 days","+3 days","+4 days");
				break;
			case 3:
				$DaysToAdd=array("-3 days","-2 days","-1 days","","+1 days","+2 days","+3 days");
				break;
			case 4:
				$DaysToAdd=array("-4 days","-3 days","-2 days","-1 days","","+1 days","+2 days");
				break;
			case 5:
				$DaysToAdd=array("-5 days","-4 days","-3 days","-2 days","-1 days","","+1 days");
				break;
			case 6:
				$DaysToAdd=array("-6 days","-5 days","-4 days","-3 days","-2 days","-1 days","");
				break;
			}	
			$WriteMonthd.="<tr>";
			for($id=0;$id<7;$id++){
				$strTempd="";
				$BGcolord="white";
				$FontColord="#000000";
				$Styled="";
				if(date("m",strtotime ("$CurrentDated $DaysToAdd[$id]"))!=$setMonthd){
					$FontColord="#999999";
				}
				if(date("m/d/y",strtotime ("$CurrentDated $DaysToAdd[$id]"))==
				date("m/d/y",strtotime($StartDated))){
					$Styled="style='border: 1pt solid red'";
				}
				$WriteMonthd.="
					<td align=center bgcolor='$BGcolord' $Styled >
								<a href='form1.php?GoToDay1="
				.$_GET['GoToDay1']."&GoToDay2="
					.date("m/d/y",strtotime ("$CurrentDated $DaysToAdd[$id]")).
					"'><font color='$FontColord'>"
					.date("d",strtotime ("$CurrentDated $DaysToAdd[$id]")).
					"</font></a></td>";
			}
			$WriteMonthd.="</tr>";
			$CurrentDated=date("m/d/y",strtotime("$CurrentDated +1 week"));
			$StartDateofWeekd=date("w",strtotime ($CurrentDated));
			$EndofWeekd=6 - $StartDateofWeekd;
			$BeginWeekd=date("m",strtotime ("$CurrentDated -$StartDateofWeekd days"));
			$EndWeekd=date("m",strtotime ("$CurrentDated +$EndofWeekd days"));
		}
	}
	$WriteMonthd.="</table></td></tr></table>";
	return $WriteMonthd;
}
$GoToDayd = $_GET['GoToDay2'];
if(!empty($GoToDayd)){
	$StartDated=date("m/d/y",strtotime ("$GoToDayd"));
}else{
	if(empty($StartDated)){
		$StartDated=date("m/d/y");
	}
}

print "<head>";
print "<style>";
print "A, TD, LI, P{font-family: $FONTd;font-size: $FONTSIZEd.pt;color: $FONTCOLORd;}
";
print "BODY{font-family: $FONTd;font-size: $FONTSIZEd.pt;}
";
print "</STYLE></head>";
print "<body>";
print "
	<table width='100%' >
		<tr>
		<td width='100'>"
		.WriteMonthd($StartDated,$BorderColord,$BarColord,1).
		"</td>
		<td><font size=1>Today's Date: "
		.date("M d, Y").
		"</font><p><font siz2=4><b>Selected start date: "
		.date("M d, Y",strtotime($StartDated)).
		"</b></font></td>
		</tr>
	</table>
";
$date2 = date("M d, Y",strtotime($StartDated));
?>

</strong></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>
      <input type="submit" name="Submit" value="Price Online">
      <input type="reset" name="Submit2" value="Reset Form">
</strong></td>

</table>
</form>
<br>
</body>
</html>

Posted: Fri Sep 03, 2004 4:11 pm
by feyd
there was no need to create a new thread. :?

Posted: Fri Sep 03, 2004 4:22 pm
by AlbinoJellyfish
Sorry, thought it needed a different one for a totally different challenge :(

Posted: Fri Sep 03, 2004 4:40 pm
by AlbinoJellyfish
If I make a link to that page, and have it pop up in a small window, have them select the date, press submit, how do I get that info back to the form1.php?

Is that even possible?

Posted: Fri Sep 03, 2004 4:57 pm
by feyd
it's possible, although not recommended.

Your dates are having problems because you aren't setting the current selected date or default date into the $GoToDay variables. So every link wipes out the sibling's date again.

Posted: Fri Sep 03, 2004 5:16 pm
by AlbinoJellyfish
Yeah, i found a snippet of javascript that does it.