All pastes #136636 Raw Edit

Miscellany

public text v1 · immutable
#136636 ·published 2006-08-17 20:16 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" dir="ltr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>live type example</title>
		<style type="text/css">
			#container {
				padding: 3px;
			}
			#replace_me {
				padding:3px;
				background-color:#cecece;
				color:#000;
				border:1px solid #000;
				width:500px;
				height:100px;
				overflow:auto;
			}
		</style>
		<script type="text/javascript" src="js/AJAXConnection.js"></script>
		<script type="text/javascript"><!--
		
		var ajax = new AJAXConnection();
		var new_data = false;
		
		ajax.onError = function() { alert("ERROR: "+ this.error); }
		ajax.onTimeout = function() { alert("The connection has timed out after "+ this.timeout +" seconds"); }

		ajax.onSuccess = function() { 
			document.getElementById("replace_me").innerHTML = this.data;
			
			if (new_data == true)
				send_data();
		}

		function send_data()
		{
			ajax.open("POST", "update_text_excersize.php", true);
			ajax.sendForm(document.forms[0], true);
			
			new_data = false;
		}
		
		function set_data()
		{
			if (!ajax.isLoading())
				send_data();
			else
				new_data = true;
		}

		//--></script>
  </head>
  <body>
		<form method="post" action="update_text_excercise.php" onsubmit="submitForm(this); return false;">
			<input type="text" name="textbox" size="30" onkeyup="set_data(this)" />
		</form>
		<br />
		<div id="container">
			<div id="head"><b>Result:</b> </div>
			<div id="replace_me"></div>
		</div>
	</body>
</html>