Topic: observe field problem

Dear Sir,

Hello ! I am new to RoR. I want to conditionally enable/disable some of the fields in my form based on the condition - value of a select tag field. I used observe for that, but it gives runtime error while opening that form that 'form is not defined' and does not work - enable/disable fields.

hdbnew.rhtml - input form
<% form_tag({ :action => 'hdbcreate' }, :multipart => true ) do %>
   <table border="2" align="center" bgcolor="#edf4fa" bordercolor="#0033CC" width="600">
        <tr bgcolor="#4171b1">
                <td width="600" height="40" colspan="4"  align="center" style="font-weight:bold; font-size:14px; color: #ffffff;
                border:none">Ad Entry </td>
        </tr>
            <tr>
              <td height="25" colspan="2" align="left" valign="top" style="font-weight:bold; font-style:italic; font-size:12px;
              color: #FF0000; border:none">
                    <%= error_message_on :adv, :prop_address %>
            </td>
            </tr>
               <tr>
               <td width="140" align="right" valign="middle" style="border:none"><span class="style28">Transaction Type </span></td>
               <td width="442" colspan="3" style="border:none"><%= select ( 'adv', 'tran_type', {'Sale' => 'S', 'Rent' => 'R'} ) %></td>
            </tr>
            <tr>
               <td width="140" height="10" style="border:none">
                   <%= observe_field(:tran_type,:update => :formulaire,  :on => :click , :url=> {:action=>'upd_trantype'}) %>
                </td>
               <td width="442" height="10" colspan="3" style="border:none"></td>
            </tr>
            <div id="formulaire">&nbsp;</div>
            <tr>
               <td width="140" align="right" valign="middle" style="border:none"><span class="style28">Create Date    </span></td>
               <td width="442" colspan="3" align="left" valign="middle" style="border:none">
              <%= datetime_select 'adv', 'create_date'  %>              
              </td>
            </tr>           
            <tr>
               <td width="140" height="10" style="border:none"></td>
               <td width="442" height="10" colspan="3" style="border:none"></td>
            </tr>
            <tr>
               <td width="140" align="right" valign="middle" style="border:none"><span class="style28">Property Type     </span>                                     </td>
               <td width="169" style="border:none"><%= collection_select ( :adv, :prop_type, @proptypes, :id, :name  ) %></td>
             <td width="123" align="right" style="border:none">Property Sub Type </td>
             <td width="170" style="border:none"><%= collection_select ( :adv, :prop_subtype, @prsubtypes, :id, :name  ) %></td>
            </tr>
            <tr>
               <td width="140" style="border:none" class="star"><p style="margin-left:10px;margin-top:0px;margin-bottom:0px">
             Rental Info</p></td>
               <td width="460" colspan="3" style="border:none"></td>
            </tr>
            <tr>
                <td width="140" height="8" style="border:none"></td>
                <td width="442" height="8" colspan="3" style="border:none"></td>
            </tr>
            <tr>
                <td width="140" align="right" valign="middle" style="border:none"><span class="style28">Deposit</span></td>
              <% if (@tran_type == 'S') %>
                   <td colspan="3" style="border:none"><%= text_field 'adv', 'rent_deposit', {"size" => 10, :disabled => true}  %></td>
                 <% else%>
                     <td colspan="3" style="border:none"><%= text_field 'adv', 'rent_deposit', {"size" => 10}  %></td>
              <% end %>
            </tr>
            <tr>
                <td width="140" height="8" style="border:none"></td>
                <td height="8" colspan="3" style="border:none"></td>
            </tr>
            <tr>
               <td width="140" height="15" style="border:none"></td>
               <td width="442" height="15" colspan="3" style="border:none"></td>
            </tr>               
            <tr>
             <td width="582" colspan="4" style="border:none" align="center"><%= submit_tag "Create" %> </td>
               </tr>
   </table>
<% end %>


advmanage_controller.rb - controller  => pls check upd_trantype action called from above form

class AdvmanageController < ApplicationController
  layout "usermanage", :except => :upd_trantype
 
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @adv_pages, @advs = paginate :advs, :per_page => 10
  end

def upd_trantype
  @tran_type = request.raw_post
  render :action => 'hdbnew'
  # @tran_type = params[:tran_type]
end

def hdblist   
    #@adv_others = AdvOther.getlist('H')
    #@adv_other_pages, @adv_others = paginate :adv_others, :per_page => 10
    @adv_pages, @advs = paginate :advs, :per_page => 10, :conditions => ["ad_type = 'H'"]
  end


def hdbnew
    @adv = Adv.new
    # @tran_type = "S"
    # Fill Drop Downs
    @proptypes = Proptype.find(:all)
    @prsubtypes = Prsubtype.find(:all)
    @hdbtowns = Hdbtown.find(:all)
    @hdbflattypes = Hdbflattype.find(:all)
    @hdbflsubtypes = Hdbflsubtype.find(:all)
    @prop_projnames = PropProjname.find(:all)
    @aparttypes = Hdbflsubtype.find(:all)
  end

def hdbcreate
    @adv = Adv.new(params[:adv])
    @proptypes = Proptype.find(:all)
    @prsubtypes = Prsubtype.find(:all)
    #@advs= Adv.find(:all)
    @hdbtowns = Hdbtown.find(:all)
    @hdbflsubtypes = Hdbflsubtype.find(:all)
    @prop_projnames = PropProjname.find(:all)
    @aparttypes = Hdbflsubtype.find(:all)
    @adv[:user_id]= 1
    @adv[:ad_type]= 'H'   

    if @adv.save
      flash[:notice] = 'AdvOther was successfully created.'
      redirect_to :action => 'hdblist'
    else
      render :action => 'hdbnew'
    end
  end
 
end


Please guide me.

Thanks & Regards,

Naimesh Trivedi