Heres my problem.
I have a page that allows users to pick a date using a javascript calendar popup.
The return value from the popup is then sent to the main page using POST - so the page loads, grabs data from a MySQL database and prints the information out. It's tabular data, so I simply drop it in a table. (I know - dont get on my case about tables - they work for tabular data very well)
Next to each returned item are a few buttons, icons that allow the person to change status or provide information to the site. Buttons like Cancel, Increment, Enter Location. A simple yes/no, no popup or enter a value.
echo'<input type = "image" src="check.gif" alt="X" onClick ="change_status('.$a.','.$m.','.$d.','.$y.')">';
Currently, they click the icon, a javascript alert box asks them to confirm the action or provide an input value and then it calls another php page that updates the database accordingly.
The function is simple: (yes, I know I can strtodate and such, but this was brute force)
function change_status($a,$m,$d,$y)
{
var r=confirm("Confirm Status Change or press Cancel to go back");
if (r==true)
{
window.location = "http:modifyrecord.php?id="+$a + "&date="+$m+"-"+$d+"-"+$y;
}
}
So far, so good.
Then the page returns to the previous page using an inline javascript that just does a window.location="themainurl" - but since the POST data is gone, they get sent back with no POST data and the PHP page defaults to loading the data from "today" using php code like this:
if (isset($POST['date']))
$date = $POST['date'];
else if (isset($GET['date']))
$date = $GET['date'];
else
$date = date('Y-m-d');
To remedy this, I send the date to the javascript function and it passes that along to the next php page
echo'<input type = "button" value = "Go Back To Schedule" onClick="goback('.$m.','.$.','.$y.')">';
the goback function just creates the window.location= values sending the data via GET something like href="themainurl?date='$date' call.
Since I handle both get and post in my script I don't really care which way it gets back. The problem is, that I have solved the problem of changing pages, but caused an additional button click to return to the schedule. Since they handle about 500 items a day, this is 500 additional clicks that I need to get rid of.
Ideally, I would like to have the php page be able to call either a javascript or php function that can:
1) Ask for confirmation or Input
2) Based on the input, handle the database update
3) Return to the page we came from WITH the POST/GET data intact.
I thought about creating a php function on the page - and I can do that, but there is no way to get the input I need to "continue" as the alert box method seems to be the simplest way.
So, how can I do this? Can I process a MySQL update on a page and then redirect to the previous page (or another page) with the POST/GET data intact? Can I process the MySQL from a javascript somehow? I seem to be dealing with server side vs client side between PHP and javascript - and neither can do the entire thing. I can't rewrite the entire setup.
Any ideas?
I have been searching for days and trying all kinds of things... No luck.