52,782
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(str){
createXMLHttpRequest();
try{
//var url="update.aspx?q=";
//url=url+encodeURIComponent(str);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET","update.aspx?q="+decodeURIComponent(str), true);
xmlHttp.send(null);
}catch(err){
alert(err.message);
} }
function handleStateChange(){
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200 || xmlHttp.status == 0){
// 取得XML的DOM对象
var xmlDOM = xmlHttp.responseXML;
// 取得XML文档的根
var root = xmlDOM.documentElement;
try
{
// 取得<info>结果
var info = root.getElementsByTagName('name');
// 显示返回结果
var aa=document.getElementById("name");
aa.innerHTML=info[0].firstChild.data;
alert("responseXML's value: " + info[0].firstChild.data);
}catch(exception)
{
}
}
}
}
</script>
</head>
<body>
<form action="">
<label>选择客户:
<select name="customers" onchange="startRequest(this.value);">
<option value="qqqii">qqqii</option>
<option value="qiqingpoi">qiqingpoi</option>
<option value="qiuqingpo@126.com">qiuqingpo@126.com</option>
</select></label>
</form>
<b><span id="name"></span></b><br />
<span id="discription"></span><br />
</body>
</html>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="c#" runat="server">
void Page_Load(object sender,EventArgs e)
{
string str1 = Server.UrlDecode(Request .QueryString ["q"].ToString());
OleDbConnection cn = new OleDbConnection("provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("update+xml.mdb"));
string sql = "select name,discription from test where name='"+str1+"'";
OleDbCommand cmd=new OleDbCommand(sql,cn);
cn.Open();
OleDbDataReader dr=cmd.ExecuteReader();
try
{
while (dr.Read())
{
Response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>");
Response.Write("<company>");
Response.Write("<name>" + dr.GetValue(0) + "</name>");
Response.Write("<discription>" + dr.GetValue(1) + "</discription>");
Response.Write("</company>");
}
}
finally
{
cn.Close();
}
}
</script>