matt.sisto Posted March 17, 2009 Share Posted March 17, 2009 This is my calendar script, I would like to be able to use the day link to open a popped up window to add an event: <?php define("ADAY", (60*60*24)); if ((!isset($_POST["month"])) || (!isset($_POST["year"]))) { $nowArray = getdate(); $month = $nowArray["mon"]; $year = $nowArray["year"]; } else { $month = $_POST["month"]; $year = $_POST["year"]; } $start = mktime (12, 0, 0, $month, 1, $year); $firstDayArray = getdate($start); ?> <html> <head> <title><?php echo "Calendar: ".$firstDayArray["month"]." ".$firstDayArray["year"]; ?></title> <head> <body> <h1>Select a Month/Year Combination</h1> <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>"> <select name="month"> <?php $months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); for ($x=1; $x <= count($months); $x++) { echo"<option value=\"$x\""; if ($x == $month) { echo " selected"; } echo ">".$months[$x-1]."</option>"; } ?> </select> <select name="year"> <?php for ($x=1980; $x<=2010; $x++) { echo "<option"; if ($x == $year) { echo " selected"; } echo ">$x</option>"; } ?> </select> <input type="submit" name="submit" value="Go!"> </form> <br/> <?php $days = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); echo "<table border=\"1\" cellpadding=\"5\"><tr>\n"; foreach ($days as $day) { echo "<td style=\"background-color: #CCCCCC; text-align: center; width: 14%\"> <strong>$day</strong></td>\n"; } for ($count=0; $count < (6*7); $count++) { $dayArray = getdate($start); if (($count % 7) == 0) { if ($dayArray["mon"] != $month) { break; } else { echo "</tr><tr>\n"; } } if ($count < $firstDayArray["wday"] || $dayArray["mon"] != $month) { echo "<td> </td>\n"; } else { echo "<td><a href='".$_SERVER['PHP_SELF']."?add=event&day={$dayArray['mday']}&month={$dayArray['mon']}&year={$dayArray['year']}'>{$dayArray['mday']}</a> </td>\n"; $start += ADAY; } } echo "</tr></table>"; ?> </body> </html> my add event script (which I would like to open in the popup window) is here: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Add Event</title> </head> <body> <legend> Event Details <form method="post" action="addevent.php"> <input type="text" name="event_title" size="25" maxlength="25" value="<?=$row['event_title']?>"/></p> <p><strong>Event Description:</strong><br/> <input type="text" name="event_shortdesc" size="25" maxlength="255" value="<?=$row['event_shortdesc']?>"/></p> <p><strong>Event Date:</strong><br/> <select name="year" value="<?=$row['y']?>"> <?php for ($x= 2009; $x<=2012; $x++) { echo "<option"; if ($x == $year) { echo " selected"; } echo ">$x</option>"; } ?> </select> <select name="month" value="<?=$row['m']?>"/> <?php $months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); for ($x=1; $x <= count($months); $x++) { echo"<option value=\"$x\""; if ($x == $month) { echo " selected"; } echo ">".$months[$x-1]."</option>"; } ?> </select> <select name="Day" value="<?=$row['d']?>"> <?php for ($x= 1; $x<=31; $x++) { echo "<option"; if ($x == $day) { echo " selected"; } echo ">$x</option>"; } ?> </select> <p><input type ="submit" value="confirm"/></p> </legend> </form> </body> </html> Any help would be greatly appreciated. Thanks and regs, Matt Link to comment https://forums.phpfreaks.com/topic/149819-calendar-with-pop-up-window/ Share on other sites More sharing options...
Brian W Posted March 17, 2009 Share Posted March 17, 2009 if you use the code tags you will likely get more help [ code ]Like this but without the spaces in the tags[ /code ] would be Like this but without the spaces in the tags Link to comment https://forums.phpfreaks.com/topic/149819-calendar-with-pop-up-window/#findComment-786724 Share on other sites More sharing options...
Festy Posted March 17, 2009 Share Posted March 17, 2009 Just modify your echo statement like below: echo "<td><a target="_blank" href='".$_SERVER['PHP_SELF']."?add=event&day={$dayArray['mday']}&month={$dayArray['mon']}&year={$dayArray['year']}'>{$dayArray['mday']}</a> </td>\n"; Link to comment https://forums.phpfreaks.com/topic/149819-calendar-with-pop-up-window/#findComment-786729 Share on other sites More sharing options...
matt.sisto Posted March 17, 2009 Author Share Posted March 17, 2009 Thanks Brian, I wondered how to display my code like that I'm relatively new to this site but now I know I will make sure to do that. Festy I have tried that but it just shows a blank page now ??? Link to comment https://forums.phpfreaks.com/topic/149819-calendar-with-pop-up-window/#findComment-786743 Share on other sites More sharing options...
Festy Posted March 17, 2009 Share Posted March 17, 2009 Festy I have tried that but it just shows a blank page now ??? Was your add event page loading in the same window before ? Link to comment https://forums.phpfreaks.com/topic/149819-calendar-with-pop-up-window/#findComment-786798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.