title: Problem with the onchange event of select box in cakePHP
body: <p>I have wriiten a below code in my view page for automatically populate select box with the first and last names of students from the session and to fill automatically the name text box with the value of the option selected from the frop down list . but the autofilling of name is not happening on selecting the option from the list.please help me out to solve this problem.</p>
  
  <pre><code>$javascript-&gt;link('jquery-1.5.1.min.js');
  $javascript-&gt;link(array('jquery', 'form'));
  $max_students = $this-&gt;Session-&gt;read('student_count');
  $student_name = array(); 
  $student_name[] = "-- Select --";
  for($i=0;$i&lt;$max_students;$i++)
  {
  
      $student_first_name     = $this-&gt;Session-&gt;read('Student.'.$i.'.FirstName');
      $student_last_name  =$this-&gt;Session-&gt;read('Student.'.$i.'.LastName');
      $student_name[]         = ($student_first_name." ".$student_last_name);
  }
  
  
  $selectDomId = $this-&gt;Form-&gt;domId('students');
    $firstnameDomId = $this-&gt;Form-&gt;domId('Name');
  
    $this-&gt;Html-&gt;scriptBlock("
        jQuery(function($){
        $('#{$selectDomId}').change(function(event){
            $('#{$firstnameDomId}').val( $(this).val() );
              });
        });
    ",array('inline'=&gt;false));
  
  
  echo $this-&gt;Form-&gt;create('Contact',array('controller'=&gt;'contacts','action'=&gt;'addcontact'));
  echo "&lt;strong&gt;Same As&lt;/strong&gt;";
  echo $this-&gt;Form-&gt;select('students',$student_name,$this-&gt;Form-&gt;domId(array(),'students'));
  echo $this-&gt;Form-&gt;input('Name');
  </code></pre>