中国高校页面,下拉框修改
This commit is contained in:
parent
c893227609
commit
e6288627ad
|
@ -32,6 +32,19 @@ class SchoolController < ApplicationController
|
|||
def index
|
||||
|
||||
end
|
||||
|
||||
def get_province
|
||||
@provinces = School.find_by_sql("select distinct province from schools")
|
||||
|
||||
options = ""
|
||||
|
||||
@provinces.each do |p|
|
||||
options << "<option value = '#{p.province}' >#{p.province}</option>"
|
||||
end
|
||||
|
||||
render :text => options
|
||||
|
||||
end
|
||||
|
||||
def get_options
|
||||
@school = School.where("province = ?", params[:province])
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
<% port = ":3000" if Rails.env.development? %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#province").html("<option value='0' selected = true style='display: none;'></option>");
|
||||
|
||||
$.ajax({
|
||||
type :"POST",
|
||||
url :'/school/get_province',
|
||||
data :'text',
|
||||
success: function(data){
|
||||
$("#province").append(data);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function get_school(value){
|
||||
$.ajax({
|
||||
|
@ -50,9 +68,9 @@
|
|||
<a href="http://course.trustie.net<%=port%>">我的学校</a>
|
||||
</p>
|
||||
<ul>
|
||||
<li style="width: 40%; float: left">请选择省份:<%= select_tag "province",
|
||||
options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province),
|
||||
:onclick => "get_school(this.value)" %></li>
|
||||
<li style="width: 40%; float: left">请选择省份:
|
||||
<select id="province" name="province" onchange="get_school(this.value)"></select>
|
||||
</li>
|
||||
<li style="width: 50%; float: left"><input type="text" id="key_word" name="key_word" />
|
||||
<input type="button" class="enterprise" value="搜索" onclick="ssearch()"></li>
|
||||
</ul>
|
||||
|
|
|
@ -581,6 +581,9 @@ RedmineApp::Application.routes.draw do
|
|||
#######confusing########
|
||||
post 'school/get_options/:province', :to => 'school#get_options'
|
||||
get 'school/get_options/:province', :to => 'school#get_options'
|
||||
|
||||
post 'school/get_province', :to => 'school#get_province'
|
||||
get 'school/get_province', :to => 'school#get_province'
|
||||
|
||||
post 'school/get_schoollist/:province', :to => 'school#get_schoollist'
|
||||
get 'school/get_schoollist/:province', :to => 'school#get_schoollist'
|
||||
|
|
Loading…
Reference in New Issue