View Single Post
Old 07-27-2008, 05:30 AM   #3 (permalink)
Third_Degree
The Wanderer
 
Join Date: Jun 2008
Posts: 5
Thanks: 1
Third_Degree is on a distinguished road
Default

To do this with no library and make it a lot easier

Code:
<script type="text/javascript">
function regenerate() {
	var ajax;
	try { 
		ajax=new XMLHttpRequest();
	}
	catch (e) {
		try { 
			ajax=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try { 
				ajax=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
			document.write("This page needs AJAX to run");
			return false;
			}
		}
	}
	ajax.onreadystatechange=function() { 
		if(ajax.readyState==4) {
			document.getElementById("string").value=ajax.responseText;
		}
	}
	ajax.open("GET","gen.php",true);
	ajax.send(null);
}
</script>
<input id="string" type="text" /> <a href="javascript: regenerate();return false;" onclick="javascript: regenerate();return false;">Regenerate</a>
And PHP:
Code:
<?php
header( 'Cache-Control: no-cache, must-revalidate' );
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
print substr( md5( rand( 0, 100 ) ), 0, 5 );
?>
__________________
Tutorials
Third_Degree is offline  
Reply With Quote