Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait message when form reloads current page

Status
Not open for further replies.

Mthales

Technical User
Feb 27, 2004
1,181
GB
Stuff like this has been posted before but I can't find anything that works for my situation so please forgive this post.

I have a form that collects a lot of information and depending on the entries various php functions run. One of these functions takes quite a long time as it calls and waits for the return from an external server side program.

The problem I am having is that when this function is necessary I would like to have a please wait message.

I've tried using onSubmit to write some html for this message but I've failed to make the first page return once the function is all done.

Could someone please point me in the direction of a better solution.

M
(Editing disabled while spellchecking)
Stop spell checking


Trainee Chocolate Management Executive.
 
Why not try something simple like:
Code:
<BODY onLoad="alert('Please be patient while page loads')">


Reality is built on a foundation of dreams.
 
overyde - Thanks for your suggestion. But I'm sorry to say that this is not working for me because the body of the html is not getting to the load event until all the stuff from the external program has completed. So this only asks the users to wait when the have done so.

jpadie - I'm looking into the product you have suggested but it seems like massive over kill for what I'm actually trying to do.

Any other ideas?
Thanks
M

Trainee Chocolate Management Executive.
 
Mthales:

i appreciate that it looks like overkill. but it's not. really!

to integrate sajax into your site for this task should take no more than a few minutes providing your code is clean.

happy to help if you need.

Justin
 
by way of totally trivial example here is some code to try on a server. you need to download the sajax.php file first, of course.

nb you need to type the whole uri into the box. ie. " to make this example work.

Code:
<?
require_once "../Sajax.php";
sajax_init();
sajax_export("get_new_contents"); 
sajax_handle_client_request(); 
function get_new_contents ($url) {
	$fh = @fopen($url, "r") or die("unable to open file");
	$contents = "";
	while (!feof($fh)):
		$contents .= fread($fh, 2048);
	endwhile; 
	fclose($fh);
	return $contents;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test for MThales</title>
<script type="text/javascript">
<? sajax_show_javascript(); ?>

function togglecontents(contents) {
	document.getElementById("masterdiv").innerHTML = contents;
}
function sajaxthisform() {
	var requesturl  = document.getElementById("input_url").value;
	togglecontents ("Please wait while the page you have requested loads");
	x_get_new_contents (requesturl, togglecontents);
}
</script>
</head>
<body>
<div id="masterdiv">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Enter a url to display: <input type="text" id="input_url" />
<br/>
<input type="submit" name="submit" onclick="sajaxthisform(); return false;"/>
</form>
</div>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top