-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html.erb
54 lines (47 loc) · 1.9 KB
/
example.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# example entry form
<tr>
<td class="f_right">Country</td>
<td><%= country_select(:profile, :country, priority_countries=['United Kingdom','United States'])%></td>
</tr>
<tr>
<td class="f_right">Location</td>
<td>
<%= observe_field :profile_country, :frequency=>0.5,
:update=>"state_select",
:url=> {:action=>'state_select', :only_path=>false},
:with=>"'country=' + encodeURIComponent(value)" %>
<div id="state_select">
<%= state_select :profile, :location, country='UK' %>
</div>
</td>
</tr>
# and put this in a partial called _state_select.html.erb
<% if params[:country] == "United States" %>
<%= state_select :profile, :location, country='US' %>
<% elsif params[:country] == "United Kingdom" %>
<%= state_select :profile, :location, country='UK' %>
<% elsif params[:country] == "England" %>
<%= state_select :profile, :location, country='UK' %>
<% elsif params[:country] == "Ireland" %>
<%= state_select :profile, :location, country='IRELAND' %>
<% elsif params[:country] == "Scotland" %>
<%= state_select :profile, :location, country='SCOTLAND' %>
<% elsif params[:country] == "Wales" %>
<%= state_select :profile, :location, country='WALES' %>
<% elsif params[:country] == "India" %>
<%= state_select :profile, :location, country='INDIA' %>
<% elsif params[:country] == "Canada" %>
<%= state_select :profile, :location, country='CANADA' %>
<% elsif params[:country] == "Australia" %>
<%= state_select :profile, :location, country='AUSTRALIA' %>
<% elsif params[:country] == "Spain" %>
<%= state_select :profile, :location, country='SPAIN' %>
<% elsif params[:country] == "Uganda" %>
<%= state_select :profile, :location, country='UGANDA' %>
<% elsif params[:country] == "France" %>
<%= state_select :profile, :location, country='FRANCE' %>
<% elsif params[:country] == "Germany" %>
<%= state_select :profile, :location, country='GERMAN' %>
<% else %>
<%= text_field :profile, :location, :class=>"text" %>
<% end %>