省份与学校的级联完成!
This commit is contained in:
parent
4da8b4e5f6
commit
37bb5341e4
|
@ -1,2 +1,15 @@
|
|||
class SchoolController < ApplicationController
|
||||
def get_options
|
||||
@school = School.where("province = ?", params[:province])
|
||||
p = params[:province]
|
||||
##@school = School.all
|
||||
options = ""
|
||||
|
||||
@school.each do |s|
|
||||
options << "<option value=#{s.name}>#{s.name}</option>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
<script type="text/javascript">
|
||||
function get_options(value){
|
||||
$.ajax({
|
||||
type :"POST",
|
||||
url :'/school/get_options/'+encodeURIComponent(value),
|
||||
data :'text',
|
||||
success: function(data){
|
||||
$("#occupation").html(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<div class="contextual" style="padding-right: 10px;">
|
||||
<%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %>
|
||||
<%= call_hook(:view_my_account_contextual, :user => @user)%>
|
||||
|
@ -72,9 +89,9 @@
|
|||
|
||||
<!-- added by Wen -->
|
||||
<p style="width:357px;padding-left: 26px;">
|
||||
<%= l(:field_occupation) %> <select name='province'><%= options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province) %></select>
|
||||
<%= l(:field_occupation) %> <%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onchange => "get_options(this.value)" %>
|
||||
|
||||
<%= select_tag 'occupation', options_from_collection_for_select(School.all, :name, :name) %>
|
||||
<%= select_tag "occupation" %>
|
||||
</p>
|
||||
|
||||
|
||||
|
|
1139
config/routes.rb
1139
config/routes.rb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue