Ammetto di aver fatto un poco di confusione. Adesso ho sistemato un poco il mio script:
File .html:
<html>
<head>
<script>
function showHint(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();
if (str.length == 4) {
alert ("la password é: "+............)
var Password=...........;
}
}
}
</script>
</head>
<body>
<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>
</body>
</html>
--------------------------------------------
File gethint.php:
<?php
// Array with names
// get the q parameter from URL
$q = $_REQUEST["q"];
$hint = "";
echo $q;
// lookup all hints from array if $q is different from ""
if ($q == "demo") {
echo "12345";
}
?>
----------------------------------------
In pratica quello che mi serve è stampare l'echo del php nella variabile password è visualizzare il risultato in alert.
Qualcuno mi sa dire come fare per favore?
Grazie molto per qualsiasi aiuto....

Rispondi quotando