dumdumsareyum Posted June 4, 2009 Share Posted June 4, 2009 I have a page that opens another page. When the "child" page (?) form is submitted it is supposed to refresh the opening page. Also, the form submits back to the same page, some code is executed, and then I was trying to use Javascript to close the page and update the opening page but it's not working and i'm not getting any errors. Here is the code for the child page which has the Javascript in it: <?php require_once("classes/tc_calendar.php"); require_once("lib/in_out.class.php"); $iob = new in_out_board(); ?> <html> <head> <script type="text/javascript"> function verifyDate(){ var currentTime = new Date(); var month = currentTime.getMonth() + 1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); returnDateString = document.out_form.date1.value; var dateArray=returnDateString.split("-"); var form_month = parseInt(dateArray[1]) - 1; var returnDate = new Date(dateArray[0], form_month, dateArray[2], 23, 59, 59); if(returnDate < currentTime) { window.alert("Date selected is cannot be before the current date current date of " + currentTime); return false; } else { return true; } function updateParent() { window.opener.document.location.reload(true); } function closeWindow() { self.close(); } } </script> <script language="javascript" src="calendar.js"></script> </head> <body> <?php if($_POST) { print_r($_POST); if($iob->verify_date()) { if($iob->verify_add_out($_REQUEST[id])) { $iob->add_out(); //close the page ?> <script type="text/javscript"> //<!-- updateParent(); closeWindow(); //--> </script> <?php } else echo "The specified employee is already out! Please check in before changing out status."; } else echo "Invalid Date. <a href=\"javascript:history.go(-1)\">[Go Back]</a>"; } $iob->display_employee_info($_REQUEST[id]); $iob->add_out_form($_REQUEST[id]); ?> </body> </html> Once the form is submitted it checks that the date entered is valid w/ Javascript and if that's ok it checks that the record is ok to be added to the database, and then it adds it with $iob->add_out(). After it's added I would like opening page to be updated and the current page to close. Not sure why it's not working. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.