Nieuw lid |
|
waarom werkt dit script dan niet:
<script language="javascript" type="text/javascript">
var url = "getCityState.php?param="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
// Split the comma delimited response into an array
results = http.responseText.split(",");
document.getElementById('city').value = results[0];
document.getElementById('state').value = results[1];
}
}
function updateCityState(test) {
http.open("GET", url + test, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
</script>
...
<form action="post">
<p>
<?php
$naam="ben";
?>
ZIP code:
<a href="javascript:updateCityState(<?php echo $naam; ?>)" name="zip" id="zip">blabla</a>
</p>
<input type="text" name="city" id="city" style="height:20;width:150;border: 0px solid #FFFFFF;">
<input type="text" name="state" id="state" style="height:20;width:150;border: 0px solid #FFFFFF;">
</form>
<script language="javascript" type="text/javascript"> var url = "getCityState.php?param="; // The server-side script function handleHttpResponse() { if (http.readyState == 4) { // Split the comma delimited response into an array results = http.responseText.split(","); document.getElementById('city').value = results[0]; document.getElementById('state').value = results[1]; } } function updateCityState(test) { http.open("GET", url + test, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } var http = getHTTPObject(); // We create the HTTP Object </script> ... <form action="post"> <p> <?php $naam="ben"; ?> ZIP code: <a href="javascript:updateCityState( <?php echo $naam; ?>)" name="zip" id="zip">blabla</a> </p> <input type="text" name="city" id="city" style="height:20;width:150;border: 0px solid #FFFFFF;"> <input type="text" name="state" id="state" style="height:20;width:150;border: 0px solid #FFFFFF;"> </form>
en als ik dan in test1.php gewoon zeg echo test dan geeft hij niets weer.
|