Really implement two list box Dynamic Association (not to write data to the page in advance and then use script to filter) (Triumph)

Source: Internet
Author: User
Think for a long time to get the method, think a lot of people are not resolved to solve the problem, in line with the principle of code sharing, now published for everyone to correct (in fact, I also feel uncomfortable). If you feel good, please help advance, so that more friends to see.
This approach is by no means writing all records to the page in advance and then filtering through the script, which, though simple, is obviously not appropriate for large amounts of data, and is a serious waste of resources.
It is convenient to apply the following code slightly to other places.
For testing purposes, first build a test.mdb Access2000 database, set up two table Type,title, the structure is as follows:
Type
******************
ID Auto number, primary key
Name text, length appropriate
Title
********************
ID Auto number, primary key
Category long shaping number, parallel type table ID field
Title text, length appropriate
Our goal is to read the record from the Type table and write it to the first list box, and then filter out the corresponding record from the Title table when the first list box is selected and write to the second list box, and you can always get the value you selected for the second list box.
Key: Place a hidden field in the b.asp to hold the value selected in the second list box, where the value of the hidden field is accessed by the script in a.asp to achieve the goal of reading values across pages.
'********************************************************
' Conn.asp connect to the database, test it with Test.mdb
'********************************************************
<%
Dim conn
Dim connstr
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" +server.mappath ("/test.mdb")
Conn. Open ConnStr
%>
'********************************************************
' a.asp homepage, inline b.asp (second list box on b.asp page)
'********************************************************
<!--#include file= "conn.asp"-->
<table>
<tr><td>

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.