title: symfony1.4, ajax, javascript jquery for dependent select
body: <p>try to write code for dynamic dependent select using jquery ajax in symfony1.4 form templates.
  I wrote code where i could take 1st fields value which is selected by the user from a dropdown list and pass it to my php function to fetch the data which is used for select the 2nd dropdown list value. i can pass the return value to ajax function from php function but i cant select my dropdown list value using this value</p>
  
  <p>here i gave my code. please give suggestion.</p>
  
  <p><strong>Code:</strong></p>
  
  <p><strong>_form.php</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      jQuery(document).ready(function() {
      $("#application_program_institution_program_id").change(function(){
              var id=$(this).val();
              if(id != '')  {
                $.ajax({
                      type: "POST",
                      url: '&lt;?php echo url_for('Application/Program'); ?&gt;'+ '?id=' + id,      
                      cache: false,
                      success: function(data)
                      {
                            alert(data);// its show my returned value
  
                           $("#application_campus_campus_id").val(data);// but it does not select the value of dropdown list.
  
                      }   
                  });
              }
          });
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Applicationaction class</strong></p>
  
  <pre><code>public function executeProgram(sfWebRequest $request) {
          $id = intval($request-&gt;getParameter('id'));
          $campusList = InstitutionCampus::getCampus($id);
          return $this-&gt;renderPartial('result', array('campusList' =&gt; $campusList));
  
      }
  </code></pre>
  
  <p><strong>getCampus Code:</strong></p>
  
  <pre><code> public static function getCampus($id) {
           $resultset = Doctrine_Query::create()
                      -&gt;select('ip.id as id, ip.program_code as title, ic.id as ip, ic.campus_name as campusname, icp.institution_campus_id')
                      -&gt;from('InstitutionCampusProgram icp')
                      -&gt;innerJoin('icp.InstitutionProgram ip')
                      -&gt;innerJoin('ip.Institution i')
                      -&gt;innerJoin('icp.InstitutionCampus ic')
                      -&gt;where('ip.all_campus = ?', '0')
                      -&gt;andWhere('i.institution_code = ?', CodeUtil::UttaraUniversity)
                      -&gt;andWhere('icp.institution_program_id =?', $id)
                      -&gt;execute();
               foreach ($resultset as $prog){
                   $result = $prog-&gt;ip;
               }
  
  
          return $result;         
       }
  
  }
  </code></pre>
  
  <p><strong>_result.php code:</strong></p>
  
  <pre><code>&lt;?php echo $campusList; ?&gt;   
  </code></pre>