How to get record in text box on change select option in HTML_QuickForm for PHP
<p>When user will select Customer Name then i want to fill Address &amp; city of that customer at run time from the database.for that i am calling javascript function on change and from that i am calling php function addfun() and trying to pass from and keyvalue for query.  I write below code but thats not working.</p>

<pre><code>    &lt;script language='javascript' type='text/javascript'&gt;
function ILovePHP(frm, a) {
var formName = frm.name;  
    alert(formName);  
b=&lt;?php addfun(formName,a);?&gt;;  

alert(b);
}
&lt;/script&gt;

    &lt;?php 

 $attrs = array("onChange" =&gt;    "ILovePHP(this.form, this.value);");   


require_once "HTML/QuickForm.php";
require_once "HTML/QuickForm/Renderer.php";
  $form = new HTML_QuickForm('customer_master', 'post');  

  $form-&gt;addElement('select','custName','Select Customer Name',$cnameAry,$attrs);  
  $form-&gt;addElement('text', 'custAdd', 'Customer Address');  
  $form-&gt;addElement('text','custCity', 'City'); 
  $form-&gt;addElement('text','custState', 'State');  

  $form-&gt;display();

  function addfun($frm, $p)
{

$query="Select  Address, City  from entityMaster where eid=$p ";


$link = mysql_connect('localhost', 'root', ''); 
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('GenInsurance');
$result=mysql_query($query);

$row=mysql_fetch_array($result);

$frm-&gt;setDefaults(array( 'custAdd'   =&gt; $row['Address'])); 
$frm-&gt;setDefaults(array( 'custCity'   =&gt; $row['Address'])); 

print $frm;
return $frm;
}

?&gt;
</code></pre>
