OK basically im confused ive got an assignment due in tomorrow night and at the moment even an example code wont work for me, basically i was reading a book and ended up with the following code but it doesn't work and i have no idea to convert this from, "user name", to an actual dictionary type suggest, basically all i wont to do is type in the message box any letter and automatically there's a drop down box that contains suggested words that have definitions but i cant seem to make it work i really need help please anyone thanks.

Here is the code

username.html

<html>
<head>

<title>username</title>
<script language="javascript">

function checkUsername(keyEvent)
{
var targetDiv = document.getElementById("targetDiv").innerHTML = "<div></div>";
var input = document.getElementById("username");

   if (input.value)
   {
     getData("username.php?qu=" + input.value);
   }
}



function getData(dataSource)
{
  var XMLHttpRequestObject = false;
  if (window.XMLHttpRequest)
  {
    XMLHttpRequestObject = new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(XMLHttpRequestObject)
  {
     XMLHttpRequestObject.open("GET", dataSource);
     XMLHttpRequestObject.onreadystatechange = function();
  {
    if (XMLhttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    {
       if (XMLHttpRequestObject.responseText == "no")
       {
       var targetDiv = document.getElementById("targetDiv");
       targetDiv.innerHTML = "<div>That word is not aviable.</div>";
       }
    }
  }

  XMLHttpRequestObject.send(null);
  }
}
</script>

</head>

<body>
<H1>Select a username</H1>

Search your username <input id = "username" type = "text" name = "username" onkeyup = "checkUsername(event)">

<div id = "targetDiv"><div></div></div>

</body>
</html>

username.php

<?php
if ($_GET["qu"] == "nancy")
{
echo "no";
}
else
{
echo "yes";
}
?>

as you can see all i want to do at this time is basically type nancy and the drop down box says no, in other words user name already used, but if i type in anything else then say yes, user name not in use.

i would really appreciate any ones help atm im so confused thanks

okay your code is a little all over the place. So you want to click a button and then check against a list of names in a database?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.