autocomplete by ajax php mysql
<p><strong>test.php</strong></p>

<pre><code>&lt;html&gt; 
    &lt;head&gt;
        &lt;script type="text/javascript"&gt;
            function callajax()
            {
                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 &amp;&amp; xmlhttp.status==200)
                    {
                        var customarray=new Array();
                        var str=xmlhttp.responseText;
                        customarray=str.split(",");
                        var obj = actb(document.getElementById('tb_name'),customarray);
                        alert(customarray[0]);
                    }
                }

                var username=document.getElementById('tb_name').value;

                xmlhttp.open("POST","fetchvalue.php",true);
                xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                xmlhttp.send("userid="+username);
            }   
        &lt;/script&gt;
        &lt;script language="javascript" type="text/javascript" src="actb.js"&gt;&lt;/script&gt;
        &lt;script language="javascript" type="text/javascript" src="common.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form action='' method='post'&gt;
            &lt;table&gt; 
                &lt;tr&gt;
                    &lt;td&gt;&lt;input type="text" name="tb_name" onkeyup="callajax();" id='tb_name'/&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;

&lt;script&gt;
&lt;/script&gt;
</code></pre>

<p><strong>fetchvalue.php</strong>
    

<pre><code>    $link = mysql_connect($host, $user, $pass);
    if (!mysql_select_db($db, $link)) {
        echo 'Could not select database';
        exit;
    } 
    $uid=$_POST['userid'];
    //$uid='a';
    $select=mysql_query("select * from login where user LIKE '%$uid%'");
?&gt;
&lt;?php 
    while($f=mysql_fetch_array($select)){
        echo $f['user'].',';
    }
?&gt;
</code></pre>

<p>its work fine but we have to use this <code>alert(customarray[0]);</code></p>

<p>plz help me..</p>
