現在、フォームがあり、ユーザーがデータを入力しているときに、このコードは別のページを呼び出して、ユーザー名が使用されているかどうかを確認します。これは、DB ページ (test.php) を呼び出すメイン ページのコードです。
<script type="text/javascript">
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
if (xmlhttp.responseText.indexOf("green") != -1) {
document.getElementById("submit").disabled = false;
} else {
document.getElementById("submit").disabled = true;
}
}
}
xmlhttp.open("GET","test.php="+str,true);
xmlhttp.send();
}
</script>
これを変更して、test.php を呼び出すときに、ユーザーが入力しているフォーム フィールドに基づいて値を test.php に渡します。
そうすれば、test.php を使用して、ユーザーが入力しているフォーム フィールドに応じて複雑な DB ルックアップを実行できます。
誰でも助けることができますか?ありがとう :)