第二级能够出来,第三级出不来啊,各位帮帮MM 我啊,  搞了两天了,没出来,急死人了!!!
<script type="text/javascript">
function showCountry(types,va){
var area = document.getElementById(types);
RequireDao.getCountry(va,{
callback:function(str){
if(str!=null){
area.options.length=0;
for(var i=0;i<str.length;i++){
var text=str[i].area;
alert(text);
var optin=new Option(text);
try{
area.add(optin);
}catch(e){
}
}
}
}
});

}
function showCarrier(types,va){
var carrier = document.getElementById(types);
RequireDao.getCarrier(va,{
callback:function(str){
if(str!=null){
carrier.options.length=0;
for(var i=0;i<str.length;i++){
var text=str[i].carrier;
var optin=new Option(text);
try{
carrier.add(optin);
}catch(e){
}
}
}
}
});
alert(carrier);
}
</script> </head>
片区:
<select id="area" name="area" class="selectcss" onchange="showCountry('country',this.value)">
<%
RequireDao dao =new RequireDao();
List<SubverCInfo> list=dao.getArea();
for(int i=0;i<list.size();i++){
session.setAttribute("area",list.get(i).getArea());
%>
<option value="<%=list.get(i).getArea()%>">
${sessionScope.area}
</option>
<%} %>
</select> 国家:
<select id="country" name="country"
onchange="showCarrier('carrier',this.value)">
<option value="">
</option>
</select>
运营商:
<select id="carrier" name="carrier" onchange="">
<option value="">
</option>
</select>
<body> </body>
</html>

解决方案 »

  1.   

    RequireDao 从数据卡读数据的方法//根据片区查询出对应的国家
    public  List<SubverCInfo> getArea(){
    Connection con=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    List<SubverCInfo> list=new ArrayList<SubverCInfo>();

    try {
    con=DBHelper.getConnection();
    pst=con.prepareStatement("select distinct(area) from dbo.subverCInfo");
    rs=pst.executeQuery();
    while(rs.next()){
    SubverCInfo cinfo=new SubverCInfo();
    cinfo.setArea(rs.getString("area"));
    list.add(cinfo);
    }

    } catch (SQLException e) {
    e.printStackTrace();
    }
    finally
    {
    DBHelper.closeResultSet(rs);
    DBHelper.closePreparedStatement(pst);
    DBHelper.closeConnection(con);
    }
    return list;
    }


    //根据国家查询出对应的运营商
    public List<SubverCInfo> getCarrier(String country){
    Connection con=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    List<SubverCInfo> list=new ArrayList<SubverCInfo>();

    try {
    con=DBHelper.getConnection();
    pst=con.prepareStatement("select distinct(carrier) from subverCInfo where country='"+country+"'");
    rs=pst.executeQuery();
    while(rs.next()){
    SubverCInfo cinfo=new SubverCInfo();
    cinfo.setArea(rs.getString("carrier"));
    list.add(cinfo);
    }

    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    finally
    {
    DBHelper.closeResultSet(rs);
    DBHelper.closePreparedStatement(pst);
    DBHelper.closeConnection(con);
    }
    return list;
    }

    //根据片区查询出对应的国家
    public  List<SubverCInfo> getCountry(String area){
    Connection con=null;
    PreparedStatement pst=null;
    ResultSet rs=null;
    List<SubverCInfo> list=new ArrayList<SubverCInfo>();

    try {
    con=DBHelper.getConnection();
    pst=con.prepareStatement("select distinct(country) from dbo.subverCInfo where area='"+area+"'");
    rs=pst.executeQuery();
    while(rs.next()){
    SubverCInfo cinfo=new SubverCInfo();
    cinfo.setArea(rs.getString("country"));
    list.add(cinfo);
    }

    } catch (SQLException e) {
    e.printStackTrace();
    }
    finally
    {
    DBHelper.closeResultSet(rs);
    DBHelper.closePreparedStatement(pst);
    DBHelper.closeConnection(con);
    }
    return list;
    }
      

  2.   

    代码太长,好晕,没看完,建议排查:1.确定js是否调用了后台。2.如果js调用了后台代码,检查数据返回是否正确。3.如果数据返回正确,检查数据的遍历显示是否存在问题。4.记得结贴!
      

  3.   

    都没问题的,只是最后没有把值填到value中去。  问题现在已经解决了,不过还是谢啦