Asp uses client arrays to store data, I have seen many such applications. But this technology has attracted my attention recently when I was studying several traffic exchange alliance systems.
Next, I will talk about how to use it. First, I will give an example of simply applying JavaScript without combining ASP.
1.js
The code copy is as follows:
vara=newArray();
vartemp="<table>";
a[0]=newArray(1,"Ah Huinan","Male");
a[1]=newArray(2,"Little White Rabbit","Female");
a[2]=newArray(3,"Xiaoqi","Female");
for(vari=0;i<a.length;i++)
{
temp=temp+"<tr>"
for(varj=0;j<a[0].length;j++)
{
temp=temp+"<td>"+a[i][j]+"</td>";
}
temp=temp+"</tr>"
}
temp=temp+"</table>";
document.write(temp);
1.html
The code copy is as follows:
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=GB2312"/>
<title>Storing data with arrays</title>
</head>
<body>
<scriptlanguage="JavaScript"type="text/javascript"src="1.js"></script>
</body>
</html>
1.html output result:
1 Ah Huinan
2 Little White Rabbit Girl
3 Little Qi Girl
Seeing the output result, you may think that we should start with that js file. Yes, we put the <scriptlanguage="JavaScript"type="text/javascript"src="1.js"></script> in 1.html
Change to <scriptlanguage="JavaScript"type="text/javascript"src="1.asp"></script>
Save 1.js as 1.asp and make the following modifications:
The code copy is as follows:
vara=newArray();
vartemp="<table>";
<%
Database connection code, open connection
Fori=1To3
IfobjRs.eofThenExitFor
%>
a[<%=i%>]=newArray(<%=objRs(0)%>,"<%=objRs(1)%>","<%=objRs(2)%>")
<%