PHP interesse |
|
form.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" rev="stylesheet" type="text/css" href="screen.css" media="screen" />
<title>MyHost</title>
<script language="javascript" type="text/javascript">
// Browser probleem
function createRequestObject() {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Problem creating the XMLHttpRequest object');
}
return req;
}
// Aanmaken object
var http = createRequestObject();
// Functie - zenden van controle
function sendRequestControle(input,value) {
http.open('get', 'controle.php?input='+input+'&value='+value);
http.onreadystatechange = handleResponseControle;
http.send(null);
}
// Functie - ontvangen van controle
function handleResponseControle() {
if(http.readyState == 4 && http.status == 200){
if(http.responseText) {
results = http.responseText.split(",");
document.getElementById("controle:"+results[1]).innerHTML = results[0];
}
}
}
</script>
</head>
<body>
<form action="" method="post">
<table width="400px">
<tr>
<td colspan="2"><b>Contact persoon</b></td>
</tr>
<tr>
<td width="50%">Naam</td>
<td width="50%">
<input type="text" name="contact_naam" id="contact_naam" size="20" onblur="sendRequestControle('contact_naam',this.value);" />
<div id="controle:contact_naam"></div>
</td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" rev="stylesheet" type="text/css" href="screen.css" media="screen" /> <title>MyHost</title> <script language="javascript" type="text/javascript"> // Browser probleem function createRequestObject() { var req; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('Problem creating the XMLHttpRequest object'); } return req; } // Aanmaken object var http = createRequestObject(); // Functie - zenden van controle function sendRequestControle(input,value) { http.open('get', 'controle.php?input='+input+'&value='+value); http.onreadystatechange = handleResponseControle; http.send(null); } // Functie - ontvangen van controle function handleResponseControle() { if(http.readyState == 4 && http.status == 200){ if(http.responseText) { results = http .responseText .split(","); document.getElementById("controle:"+results[1]).innerHTML = results[0]; } } } </script> </head> <body> <form action="" method="post"> <table width="400px"> <tr> <td colspan="2"><b>Contact persoon</b></td> </tr> <tr> <td width="50%">Naam</td> <td width="50%"> <input type="text" name="contact_naam" id="contact_naam" size="20" onblur="sendRequestControle('contact_naam',this.value);" /> <div id="controle:contact_naam"></div> </td> </tr> </table> </form> </body> </html>
controle.php
<?php
if(isset($_GET['input']) && isset($_GET['value'])) {
$goed = "<img src=\"_images/vinkje.png\" alt=\"\" />";
$fout = "<img src=\"_images/vinkje.png\" alt=\"\" />";
if($_GET['input'] == "contact_naam") {
return "contact_naam,".$goed;
}
}
?>
<?php if(isset($_GET['input']) && isset($_GET['value'])) { $goed = "<img src=\"_images/vinkje.png\" alt=\"\" />"; $fout = "<img src=\"_images/vinkje.png\" alt=\"\" />"; if($_GET['input'] == "contact_naam") { return "contact_naam,".$goed; } } ?>
wat kan er fout gaan?
|