存储城市信息,选择某个城市,相应的城市的区号、邮编、城市等级也显示出来。

解决方案 »

  1.   

    LZ:思路应该是当你选择城市下拉框,onchange改变的时候,调用一个ajax请求,查询出这个城市对应的bean信息,之后返回json,在jsp页面在给区号,邮编赋值!
      

  2.   


    $.ajax({
    url : "自己请求的action,或者servlet地址",
    data : "cityID=" + cityID,
    type : "post",
    dataType : "json",
    success : function(date) {
    document.getElementById("postCode").value=data.postCode;
    document.getElementById("cityQuHao").value=data.cityQuHao;
    }
    });
    action 或者servlet代码
    JSONObject json = new JSONObject();
    json.put("postCode","10010");
    json.put("cityQuHao","001001");
    super.response().setCharacterEncoding("UTF-8");
    super.response().setContentType("text/javascript");
    PrintWriter printWrite=null;
    try {
    printWrite = super.response().getWriter();
    printWrite.write(json.toString());

    } catch (IOException e) {
    logger.error(e, e);
    }finally{
    if(printWrite!=null){
    printWrite.close();
    }
    }
      

  3.   

    这个你前台是jsp吧,这个的用到ajax,楼主你试试吧。主要是思路先通了!