input界面用的下拉列表框ajax交互

sinosoft

var select = "<select id='transferCatalog"+(parseInt(index)+1)+"' name='transferCatalog"+(parseInt(index)+1)+"' οnchange='onChangeHandleCatalog(this, this.value,"+(parseInt(index)+1)+")'>";
		    select += "<option value=''>-请选择-</option>";
		    
		if (value != "") {
			var retValue = $.ajax({
					   async:false,
					   type: "POST",
					   url: "opine-query!getCatalogsByNodeParent.action",
					   data: "nodeParent=" + value+"&node="+index,
					   success: function(msg){
					     //alert( "Data Saved: " + msg );
					   }
					}).responseText;
			//alert("retValue" + retValue);
			if(retValue == ""){
				alert("获取分类信息失败。");
				return;
			} 
			// 解析json对象
			var dataObj = eval("("+retValue+")");
			
			$.each(dataObj,function(idx,item){
				select += "<option value='" + item.CATALOG + "'>"+ item.NODE_NAME +"</option>";//sql查的字段
                     
			}); 
		}
		 
		select += "</select>";
		$(selectObj).after(select);



OpineQueryAction里面。
	/**
	 * 根据上级分类获取下一级分类信息
	 */
	public void getCatalogsByNodeParent() {
		try {
			List<Map<String, Object>> catalogList = opinionManager.getCatalogByNodeParent(nodeParent,node);
			
			//获取HttpServletResponse,将用户登录信息返回前台
			HttpServletResponse response = ServletActionContext.getResponse();
			response.getWriter().print(JSONArray.fromObject(catalogList).toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


无刷新页面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript">
	
	var xmlhttp;
	function createRequest(){
	  if(window.ActiveXObject){
	    xmlhttp=new ActiveXObject("msxml2.xmlhttp");
	  }else{
	     xmlhttp=new XMLHttpRequest();
	  }
	}

	  function init(){
	     createRequest();//1
	     xmlhttp.onreadystatechange=function(){//2
	       if(xmlhttp.readyState==4){
		       if(xmlhttp.status==200){
		         t=xmlhttp.responseText;
		         document.getElementById("pr").innerHTML=t;
		       }
	       }
	     }
	     
	     xmlhttp.open("GET", "<%=basePath%>ajax.jsp", true);
	     
	     xmlhttp.send(null);
	     
	    
	  }
	  
	  function zhaocity(xx){
	    alert(xx);
	  }
	</script>
  </head>
  
  <body οnlοad="init();">
    <form>
     
      请选择省<div id="pr"><select name="province" id="province">
           <option id="0">--请选择省--</option>
           
         </select></div>
    </form>
  </body>
</html>


代理页面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.bluedot.jclg.dao.EmpDAO"%>
<%@page import="com.bluedot.jclg.vo.Areas"%>
<%
  EmpDAO dao=new EmpDAO();
  String fid=request.getParameter("fid");
  StringBuffer sb=new StringBuffer("<select name='province' id='province' οnchange='zhaocity(this.value)'><option>--ppp--</option>");
  //if(fid!=null){
    Set<Areas> s=dao.query(0); 
    Iterator it=s.iterator();
    while(it.hasNext()){
      Areas a=(Areas)it.next();
      sb.append("<option value="+a.getId()+">"+a.getName()+"</option>");
    }
    sb.append("</select>");
    out.println(sb.toString());
    out.flush();
  //}

%>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值