Select|xml
This is another application of XMLHTTP on "using XMLHTTP to get data without refreshing".
About XMLHTTP. It can be said that it is a good bonding agent. The distance between the client and the server is narrowed.
Using XMLHTTP, we can achieve a lot of good ideas.
This article. Implemented a two-level tandem select.
The traditional two-level link is to upload all the data to the client.
Using XMLHTTP, we can return the data we need in real time.
Select.htm
[Copy this Code] CODE:
Please Select Fujian Province Hubei Province Liaoning Province
Server.asp server-side processing.
[Copy this Code] CODE:
<% @Language = "Javascript"%>
<%
function Opendb (sdbname)
{
/*
*---------------opendb (sdbname)-----------------
* OPENDB (Sdbname)
* Function: Open database Sdbname, return conn object.
* Parameters: Sdbname, String, database name.
* Example: var conn = opendb ("Database.mdb");
* AUTHOR:WANGHR100 (Grey bean baby. NET)
* Update:2004-5-12 8:18
*---------------opendb (sdbname)-----------------
*/
var connstr = "Provider=Microsoft.Jet.OLEDB.4.0;" Data source= "+server.mappath (sdbname);
var conn = Server.CreateObject ("ADODB.") Connection ");
Conn. Open (CONNSTR);
Return conn;
}
var oconn = opendb ("Data.mdb");
var province = Request ("sel");
var arrresult = new Array ();
var sql = "Select City" where Province= ' "+province+" ";
var rs = Server.CreateObject ("ADODB.") Recordset ");
Rs. Open (sql,oconn,1,1);
while (!rs. EOF)
{
Iterate through all the appropriate data into the Arrresult array.
Arrresult[arrresult.length] = RS ("city"). Value;
Rs. MoveNext ();
}
Escape solved the XMLHTTP. Chinese to deal with the problem.
Array group to synthesize strings. is connected by a string of ",".
Response.Write (Arrresult.join (","));
%>
Database design
Data.mdb
Table.
Field
ID Auto Number
Province text
City text
Table: Our data:
ID Province City
1 Fuzhou City, Fujian Province
2 Xiamen, Fujian Province
3 Quanzhou, Fujian Province
4 Wuhan City, Hubei Province
5 Jingzhou City, Hubei Province
6 Yichang City, Hubei Province
7 Shenyang City, Liaoning Province
8 Dalian City, Liaoning Province
9 Panjin, Liaoning Province