首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >asp: AJAX Database

asp: AJAX Database

作者头像
geovindu
发布2026-06-19 09:27:05
发布2026-06-19 09:27:05
630
举报
代码语言:javascript
复制
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>AJAX Database</title>
<script type="text/javascript">

function showCustomer(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }

//str=document.getElementById("customers").value;
//alert(str);
xmlhttp.open("GET","getcustomer.asp?q="+str,true);
xmlhttp.send();
}
</script>
</head>

<body>
<form action=""> 
<select name="customers" id="customers" onchange="showCustomer(this.value)">
<option value="">Select a customer:</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
<br/>
<div id="txtHint">Customer info will be listed here...</div>
</body>

</html>

代码语言:javascript
复制
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>

<%
response.expires=-1
'q=ucase(request.querystring("q"))
sql="SELECT * FROM users WHERE ID="
sql=sql & "" & request.querystring("q") & ""
'response.write q;


set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("dbgeovindu.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open sql,conn

response.write("<table>")
do until rs.EOF
  for each x in rs.Fields
    response.write("<tr><td><b>" & x.name& "</b></td>")  '字段名
    response.write("<td>" & x.value& "</td></tr>") '值名
  next
  rs.MoveNext
loop
response.write("</table>")
%>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013-12-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档