
Originally Posted by
Mav3n
In my form I have an input box that asks for a name...
As the user enters the name, I would like the javascript to access the MySQL db and look for names that match this entry. If it matches any of the entries it will display the name with a nice little message next to the input box..."Name Exists"
How would I go about doing this? Can someone point me to a tutorial or in the right direction?
Hi Mav3n!
For this to work you will first have to know the basic concept of AJAX. After you know this, you can do it very easily.
Following are few codes that might help you:
1. You should have a form with input box and put a onSubmit function. The function should look like this:
2. The function should look some thing like this:
Code:
function abc()
{
var xhReq;
xhReq = createXMLHttpRequest();
xhReq.open('get', 'test_ajax.php?id='+ document.ajax_ex.ajax_select.selectedIndex);
xhReq.onreadystatechange = onSumResponse;
xhReq.send(null);
}
3. Now this function acts as an AJAX Engine and would communicate with test_ajax.php (in this example code) to process your request (access the MySQL db and look for names that match this entry). Now the file which would actually process your request would be test_ajax.php where you can put codes so that it queries your mysql database and echoes the result.
<self promotion is not allowed>
Regards,
Mani.
Bookmarks