代码
$(function(){   
   $(
"#area_parentID").change(function(){   
       $(
"#next_select").html("<select name='streat' id='streat'></select>");   
       $.post(    
       
"/banks/select_with_ajax",   
       {
"parentID":$("#area_parentID").val()},   
       
function(data){   
          
var datas = eval(data);   
      
//alert(datas);   
      $.each(datas,function(i){   
              $(
"<option value='"+datas[i].area.id+"'>"+datas[i].area.name+"</option>").appendTo($("#streat"));   
          });          
       });   
   });   
});

 

代码
<tr>  
<td>地域</td><td><%=    
  @areas 
= Area.find(:all, :select => 'name,id',:conditions=>"parentID=0").collect{|t| [t.name,t.id]}.insert(0,["请选择",0])          
  select("area","parentID",@areas,{},{:selected=>1})%><span id='next_select'><select name="streat" id="streat"></select></span></td>  
</tr> 

 

代码
def select_with_ajax             
      @areas 
= Area.find(:all, :select => "name,id",:conditions => ["parentID = ?", params[:parentID]])                 
      render(:json 
=> @areas.to_json,:layout => false)   
  end  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-05-25
  • 2022-12-23
  • 2021-11-29
  • 2021-09-16
  • 2021-10-31
  • 2022-12-23
  • 2021-06-13
相关资源
相似解决方案