Use ASP + JavaScript to realize dynamic data linkage, do not refresh

zhaozj2021-02-17  72

/ by xxrl (Kong Cheng Chengren, Meng Shu took E)

/ Chinese: Jiang Jianhua

/EMAIL :JJH_115@eyou.com

Link, linkage, linkage. . . . It has plagued a lot of nerves of many netizens. In the 9CBS-ASP sector, always see the netizens call your life, what? Linkage! Why is it concerned about this, and the user can be recognized, but if the data is a lot and interrelated, the problem is coming, how to identify and display is a very distressed problem. Is there a good solution? The answer is yes, because we have ASP and JavaScript, haha, then we start to act!

The data we have to get, since the effect of linkage is to achieve, affirm that these data is related, then we use this example to explain our method.

Preparation conditions:

SQL Server 2000 Chinese Enterprise Edition, IIS5.0 , IE5.0 , of course, there is a good editor, vs.net is good, of course, if you are a notepad's support, then I have no way. . L

In order of the explanation of the department level in personnel management, we can define this in the departmental level in management, and the definition rules of actual enterprises, ** Chemical Plant / ** System / **, for example,

× × Chemical Plant / Marketing System / Marketing Department, in the article, the first "× × Chemical Plant", the secondorganization corresponds to the "marketing system", the "Margarganization" is "Marketing"

Built two tables in SQL Server 2000, or three tables, in order to play the linkage of linkage, we can build three tables, huh, huh.

Database Name: XXRL_Study, User Name XXRL_STUDY, Password XXRL_Study

You can also build an ODBC data source, you can use it, but I use it like this, huh, huh

ODBC name: XXRL_ ODBC, use user name xxrl_study, password xxrl_study, point to XXRL_Study Database, Default Chinese Settings, Test -> OK

New Table:

First table firstorganization

The SQL script is as follows:

if EXISTS (Select * from dbo.sysObjects where id = Object_id (n '[dbo]) and ObjectProperty (id, n'susertable') = 1)

Drop Table [DBO]. [FirstOrganization]

Go

Create Table [DBO]. [FirstOrganization] (

[ID] [INT] Identity (1, 1) Not NULL,

[OrganizationName] [varchar] (100) collate chinese_prc_ci_as not null,

[Description] [varchar] (8000) Collate Chinese_prc_ci_as null

) On [primary]

Go

Second table secondorganization

The SQL script is as follows:

If EXISTS (Select * from dbo.sysObjects where id = Object_id (n '[dbo]) and ObjectProperty (id, n'susertable') = 1) DROP TABLE [DBO]. [SECONDORGANIZATION].

Go

Create Table [DBO]. [SECONDORGANIZATION]

[ID] [INT] Identity (1, 1) Not NULL,

[parentid] [int] Not null,

[OrganizationName] [varchar] (100) collate chinese_prc_ci_as not null,

[Description] [varchar] (8000) Collate Chinese_prc_ci_as null,

[ORDERNUMBER] [INT] NULL

) On [primary]

Go

Third Table Thirdorganization

The SQL script is as follows:

If exists (select * from dbo.sysObjects where id = Object_id (n '[dbo]) and ObjectProperty (ID, n'susertable') = 1)

Drop Table [DBO]. [thirdorganization]

Go

CREATE TABLE [DBO]. [Thirdorganization]

[ID] [INT] Identity (1, 1) Not NULL,

[parentid] [int] Not null,

[OrganizationName] [varchar] (100) collate chinese_prc_ci_as not null,

[Description] [varchar] (8000) Collate Chinese_prc_ci_as null,

[ORDERNUMBER] [INT] NULL

) On [primary]

Go

OK, ODBC, we are built, the database is also built, as for the configuration of the site, I think everyone should know, here no longer state. Here my site IP is http://200.100.100.88 (internal network IP)

I finally started writing the program, so tired,, 哧, just helped my colleague to move things, rest for a while, coffee-ing ........

Ok, in order to facilitate IIIs, he is too lazy to knock extra letter. We are smart, unstoppable programmers, the programmer is already tired, it is not convenient for us ourselves? Hey, agrees applaud, 啪, faint, where is the firecracker? The child's child is not good. . . . . . . . . J

New Default.asp file, we are writing as follows,

Establish a database connection object,

Set objconn = server.createObject ("adoDb.connection")

Objconn.open "xxrl_ odbc", "xxrl_study", "xxrl_study"

Then open the three data sets we want to do

DIM SQL1, SQL2, SQL3

SQL1 = "SELECT * from first," SQL2 = "Select * from secondorganization"

SQL3 = "SELECT * from thirdorganization"

'/ Open the first organizational library

SET RS1 = Server.createObject ("AdoDb.Recordset")

RS1.Open SQL1, OBJCONN, 1, 1

SET RS2 = Server.createObject ("AdoDb.Recordset")

RS2.Open SQL2, Objconn, 1, 1

SET RS3 = Server.createObject ("AdoDb.Recordset")

RS3.Open SQL3, OBJCONN, 1, 1

Built a SELECT type HTTP control, which is included in the Form form:

The initial value of the 'control is read from the FirstOrganization. The first data in this example is that the XX chemical plant code is as follows:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<%

IF r2.recordcount <0 THEN

Response.write "

Else

While Not Rs2.eof

Response.write "

RS2.MOVENEXT

Wend

END IF

%>

OK, the second is also done, let's build the third Select is also placed in the Form form, as follows: