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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I had the same problem up until a couple of minutes ago. Try this:
with =>
"''purchaser_country_id=#{purchaser_country_id}&purchaser_zipcode=''+encodeURIComponent(value)"
Sean
On Aug 24, 3:42 pm, Philip Nelson
<team...-RvFq4O/J5Z7QT0dZR+AlfA@public.gmane.org>
wrote:> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Sean, Thanks for that : I managed to resolve this last night (with the same solution) after some help on the RoR chat forum. Thanks very much. Phil On Saturday 25 August 2007 19:21, schof wrote:> I had the same problem up until a couple of minutes ago. Try this: > > with => > "''purchaser_country_id=#{purchaser_country_id}&purchaser_zipcode=''+encodeUR >IComponent(value)" > > Sean > > On Aug 24, 3:42 pm, Philip Nelson <team...-RvFq4O/J5Z7QT0dZR+AlfA@public.gmane.org> wrote: > > 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 > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---