I need to pass through two parameters to a controller method from an observe_field : the value of the field and another local variable.
I can get it working for either of the two, but not for both.
This is what I'm got in the form partial I'm trying to write (purchaser_country_id is coming in as a :local) -
<p><label for="order_purchaser_zipcode">Zip Code</label><br/> <%= text_field 'order', 'purchaser_zipcode', :size => 20 %> </p>
<% if Zipcode.exists?(["state_id in (select id from dbfox001.states where country_id = ?)", purchaser_country_id]) %> <!-- Enable zipcode searching if we have zipcodes for the country at all --> <%= 'Zipcodes exist for ' + purchaser_country_id.to_s %> <%= observe_field :order_purchaser_zipcode, :update => 'purchaser_loc2', :url => { :controller => 'order', :action => 'findzip' }, :with => "'purchaser_country_id='+purchaser_country_id.to_s+'&purchaser_zipcode='+encodeURIComponent(value)" %> <% else %> <!-- If no zipcodes exist then just use standard text entry boxes --> <%= 'No zipcodes for ' + purchaser_country_id.to_s %> <% end %>
<div id='purchaser_loc2'> <%= render :partial => "purchaser_location2", :locals => {:purchaser_country_id => purchaser_country_id, :purchaser_zipcode => ''} %>
<p><label for="order_purchaser_city">City</label><br/> <%= text_field 'order', 'purchaser_city', :size => 50 %></p> </div>
If one of the fields is a literal it works : for example -
:with => "'purchaser_zipcode='+encodeURIComponent(value)+'&purchaser_country_id='+'101'"
Any help appreciated.
Thanks
Phil