[SOLVED]Using two scripts on one page

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
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

[SOLVED]Using two scripts on one page

Post by AlbinoJellyfish »

I have a page with two calendar scripts both in there, but they dont seem to work. When you click a date, the calendar you clicked on doesnt update. It also forgets what the previous date of the other script was.

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?
$GoToDay1 = $_GET['GoToDay1'];
$GoToDay2 = $_GET['GoToDay2'];
?>
<body>
Please enter all information.
<form name="form1" method="post" action="form2.php">
<table width="411" height="361" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="391"><p><strong>Platform:</strong></p>
      <p>GEM-Lightning.........................................................................<br>
      GEM-Thunder..........................................................................<br>
    PCMCIA (EDI Approved).......................................................</p></td>
    <td width="20">        <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=".$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=".$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?GoToDay="
					.date("m/d/y",strtotime ("$CurrentDate $DaysToAd[$i]")).
					"GoToDay2=".$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($GoToDay)){
	$StartDate=date("m/d/y",strtotime ("$GoToDay1"));
}else{
	if(empty($StartDate)){
		$StartDate=date("m/d/y");
	}
}

print "<html><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="
				.$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="
				.$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="
				.$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 "<html><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>
Last edited by AlbinoJellyfish on Fri Sep 03, 2004 4:06 pm, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

problem 1: you are printing 3 html starts.
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

Post by AlbinoJellyfish »

ok, so minus the html starts, it still doesnt work. here is a link. http://prototype.edienterprises.com/mat ... /form1.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

reading the html output, $GoToDay1 and $GoToDay2 are both blank in the links.

side note: your <<< and >>> should to be entitied.
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

Post by AlbinoJellyfish »

Yeah, I figured it out, i just used

Code: Select all

<? $_GET['GoToDay1']?>
instead of the

Code: Select all

<?$GoToDay1 = $_GET['GoToDay1']; 
?>
in the links
Post Reply