A two-level continuous select with XMLHTTP implementation

Source: Internet
Author: User
Tags array copy sql net return string client
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.