Dropdown Selected value in Textbox PHP
<p>***Possible solution given in other question is not working here...</p>

<p>Hi I want to select value from dropdown and fetch in Textbox</p>

<p>This below code is fetching value from database but it is not putting in textbox. textbox below is named as emp_number and name of my dropdown is dealer</p>

<p>Please have a look</p>

<pre><code>&lt;?php


include 'connect-db.php';

//mysql_select_db("my", $con);
$s=mysql_query("select * from employees order by emp_number asc "); 
?&gt;
   Select Employee Number:

   &lt;select name="dealer" id="dealer" onchange='updateMyText()'&gt;
   &lt;option value=""&gt;---- Select employee Number -----&lt;/option&gt;

    &lt;?php
  while($dd=mysql_fetch_array($s))
{
?&gt;
    &lt;option value="&lt;?php echo $dd['emp_id'] ?&gt;"&gt;&lt;?php echo $dd['emp_number']       ?&gt;&lt;/option&gt;
 &lt;?php
}
    ?&gt;                  
&lt;/select&gt;

&lt;html&gt;
&lt;head&gt;
        &lt;title&gt;PHP insertion&lt;/title&gt;
    &lt;link rel="stylesheet" href="css/insert.css" /&gt;
    &lt;link rel="stylesheet" href="css/navcss.css" /&gt;
    &lt;script type='text/javascript'&gt;
    /*$('#dealer').change(function () {
         $("#emp_number").val($(this).val());*/
             function updateMyText()
{
var dd = document.getElementById("dealer");
var ddtext = dd.options[dd.selectedIndex].text;
document.getElementById('emp_number').value = ddtext;
}
&lt;/script&gt;

    &lt;/head&gt;
    &lt;body&gt;
            &lt;div class="maindiv"&gt;
                    &lt;br /&gt;
                    &lt;label&gt;Employee Number:&lt;/label&gt;
                &lt;br /&gt;
                &lt;input class="input" type="text" name="emp_number" value="" /&gt;
                &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt; 
</code></pre>