populating textbox from dropdown in php & mysql
<p>I am new in this forum..Forgive me for any kind of mistake &amp; help me.
I have a form with only two fields,first one textfield &amp; next dropdown list.Now I want to show value in list from database based on textfield value from database.i.e If I type perfect username it will show me in dropdown the corresponding emailid(s) of that user.It will change after the username being changed.</p>

<p>Hope someone will help me in this matter.I was working a long time,but cant satisfied.Thanks in advance.This is the code what I have tried.But I want just the reverse.</p>

<p>`    
     function CBtoTB()
     {document.getElementById("username").value=document.getElementById("usernameselect").value}
    </p>

<pre><code>&lt;?php  
$result=mysql_query("select Username from users"); 
$options=""; 
while ($row=mysql_fetch_array($result)) { 
$username=$row["Username"]; 
$options.="&lt;OPTION VALUE=\"$username\"&gt;".$username.'&lt;/option&gt;'; 
} 
?&gt;
&lt;select name="usernameselect" id="usernameselect" onchange="CBtoTB()"&gt;
&lt;option value=""&gt;&amp;lt; select user &amp;gt;&lt;?php echo $options ?&gt;&lt;/option&gt;
&lt;/select&gt;
&lt;input name="username" type="text" id="username" value="&lt;?php echo $username ?&gt;"       size="25" readonly="readonly" /&gt;`
</code></pre>
