您的位置:首页 > 数据库

一段歪曲了概念的脚本,JS怎么能读服务器上的数据库呢??

2006-06-07 19:01 316 查看
<select size="1" name="location" onChange="changelocation(document.Form1.location.value)" language="JavaScript">
<option value="US" >US Server </option>
<option value="EURO">EU Server</option>
</select>
<span id="SvrName">
<select size="1" width="10" name="ServerName" id="ServerName" >
<option value="">Select Your Server</option>
</select>
</span>
<script language ="JavaScript">
function changelocation(location)
{
var StringSvrName;
var StrSelect;
var SqlString;
SqlString="Select * from GoldPrice where Location='"+location+"' and Faction='Alliance' Order By ServerName,Faction";
alert(SqlString);
StrSelect="<option value=''>Select Your Server</option>";
<%
Set conn = Server.CreateObject("ADODB.Connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=" & Server.MapPath("../../database/gamesavornews.mdb")
conn.Open Strconn
set rs=server.CreateObject("adodb.recordset")
sql="Select * from GoldPrice where Faction='Alliance' Order By ServerName,Faction"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
%>
StrSelect=StrSelect+"<option value=''>No Server</option>";
<%
else
for i=1 to rs.recordcount
%>
StrSelect=StrSelect+"<option value='<%=replace(rs("ServerName"),"'","''")%>' ><%=replace(rs("ServerName"),"'","''")%></option>";
<%
rs.movenext
next
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
StringSvrName="<select size='1' width='10' name='ServerName' id='ServerName'>";
StringSvrName=StringSvrName+StrSelect;
StringSvrName=StringSvrName+"</select>";
document.all.SvrName.innerHTML=StringSvrName;
alert(StrSelect);
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐