Topic: form_tag rails 3

I am trying to use remote form in Rails 3.0.6.
--> When I click on "Search" button, the callback goes to controller, but the "results_patient_div" is not updated.
--> On the other hand, when I hit return key within any of the text fields, "results_patient_div" is filled with results.
Any help with getting the "Search" button to work as expected is appreciated. Thanks!


  View:       search.html.erb

  
  <%= form_tag(url_for(:controller => "patients", :action => "show_matching_patients"), :remote => true, :method => :post, :update => "results_patient_div", :id => 'patient_search_form') do %>  
  
  <div id="search_patient_div", style="position: relative; z-index: 0; display: block; background: transparent">
  
  <div id = "search_fields_div", style="position: relative; width: 800px; top:10px; z-index: 0"> 
    <font size="1">
  <b> Last Name: </b> <%= text_field('patient','lname', {:class => 'textbox1', :onkeypress => remote_function(:url => { :action => "show_matching_patients"}, :update => "results_patient_div", :with => "$('patient_search_form').serialize()", :condition => 'event.keyCode == 13')}) %>
    <b> First Name: </b> <%= text_field('patient','fname', {:class => 'textbox1', :onkeypress => remote_function(:url => { :action => "show_matching_patients"}, :update => "results_patient_div", :with => "$('patient_search_form').serialize()", :condition => 'event.keyCode == 13')}) %>      
    <b> Study ID:</b> <%= text_field('patient','studyid', {:class => 'textbox1', :onkeypress => remote_function(:url => { :action => "show_matching_patients"}, :update => "results_patient_div", :with => "$('patient_search_form').serialize()", :condition => 'event.keyCode == 13')}) %>      
    <%= submit_tag( "Search") %>          
  </font>
  </div>
  </div>
  
  <% end %>
  
  <p>
  <div id="results_patient_div", style="position: relative; top:10px; z-index: 0">
  </div>   
  </p>


  Controller:    patients_controller.rb


  def show_matching_patients
    
    session[:validation_errors] = []
  
  # Obtain form data    
  @lname = params['patient']['lname']  
    @fname = params['patient']['fname']  
  @studyid = params['patient']['studyid']  
  @lname = @lname.strip
  @fname = @fname.strip
  @studyid = @studyid.strip
  
  # Name-lookup
  @matching_patients = Patient.find(:all, :conditions => 'last_name LIKE "'+"#{@lname}"+'"')  
  
  @total = @matching_patients.length
  
    session[:total_matches] = @total  
  
  render :partial => "show_matching_patients"
  
  end


  Partial:    _show_matching_patients.rhtml

<html>
  
  <span style=""> 
  
  <br/>
 
  <% if session[:total_matches] == 0 %>
  
  <hr>
  <h5> No patients matched search criteria. </h5>
    
          
  <% elsif session[:total_matches] > 0 %>
    
  <b> Following patient(s) matched search criteria: </b>  
     
  <table cellpadding="2" cellspacing="0" border="0" frame="border">
    
  <th style="width: 125px", align="center"> <font size="1"> Patient ID </font> </th>
  <th style="width: 125px", align="left"> <font size="1"> Last Name </font> </th>
  <th style="width: 125px", align="left"> <font size="1"> First Name </font> </th>
  <th style="width: 125px", align="center"> <font size="1">  </font> </th>


  <% odd_or_even = 1
  for patient in @matching_patients
    odd_or_even = 1 - odd_or_even %>
    <tr valign="top" class="ListLine<%= odd_or_even %>">    

      <td width="125px", align="left"><font size="1">  
      <%= patient.id %>
        </font></td>
                  
      <td width="125px", align="left"><font size="1">  
      <%= patient.last_name %>
        </font></td>

      <td width="125px", align="left"><font size="1">  
      <%= patient.first_name %>
        </font></td>

      <td width="125px", align="left"><font size="1">  
      <%= button_to("show images", :action => "show_images", :patient_id => patient.id)  %>
        </font></td>  
        
        </tr>
        
    <% end %>

  </table>
  
  </font>
  
  <% end # loop for matches-found %>

  </span>
    
</html>