关闭

xmlhttp通过javascript调用jsp代码

1288人阅读 评论(1) 收藏 举报

<script language="javascript">
if(document.getElementById("htmleditcontent")!=undefined){interform.temp.value = document.getElementById("htmleditcontent").value;WBTB_InitDocument('Body','GB2312');}</script>
<script language="javascript">
{
xml = new ActiveXObject("Microsoft.XMLHTTP");
var post="";//构造要携带的数据
xml.open("POST","../jsp/queryCS/test.jsp?cs=11",false);//使用POST方法打开一个到服务器的连接,以异步方式通信
xml.setrequestheader("content-length",post.length);
xml.setrequestheader("content-type","application/x-www-form-urlencoded");
xml.send(post);//发送数据
//返回结果
var v = xml.responseText;
//处理这个结果
document.getElementById("selectfact").innerHTML='<SELECT size=1 name=postercn>' + v ;
}
</script>

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*"%>
<%@ page import="java.util.List"%>
<%@ page import="com.yc.ycportal.util.CacheTree"%>
<%@ page import="java.util.StringTokenizer"%>
<html><BODY>
<%
   String strchangshang=(String)request.getParameter("cs");
   String cname=(String)request.getParameter("cscn");
   String allquery_str="";
   System.out.println("厂商"+strchangshang);
  String all_factory="";
  // 

  {
      List list = CacheTree.getAll_son_Tree(strchangshang);
      String str_fact_id_name = "";
      String fact_id = "";
      String fact_name = "";
      for (int i = 0; i < list.size(); i++) {
       str_fact_id_name = (String) list.get(i);
       StringTokenizer st = new StringTokenizer(
         str_fact_id_name, "◆");

       fact_id = st.nextToken();
       fact_name = st.nextToken();

       if ("".equals(allquery_str))
        allquery_str = fact_id + "◆" + fact_name;
       else
        allquery_str = allquery_str + "|" + fact_id
          + "◆" + fact_name;// 为后边查询做准备

       all_factory = all_factory + "<OPTION value="
         + fact_name + ">" + fact_name + "</OPTION>";
      }
  }
  if("".equals(all_factory))
     all_factory="<OPTION value="+ cname + ">" + cname + "</OPTION>";
%>
<%=all_factory%>
</BODY>
</html>

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3277592次
    • 积分:27921
    • 等级:
    • 排名:第198名
    • 原创:334篇
    • 转载:552篇
    • 译文:7篇
    • 评论:331条
    最新评论
    艺术设计类