The ASP uses the client array to store the data, which I have seen a lot. But this technique has attracted my attention recently in the study of several sets of traffic-Exchange Alliance systems.
Let me talk about how to use, first of all, to give a combination of ASP, the simple application of JavaScript examples.
1.js
Copy Code code as follows:
var a = new Array ();
var temp = "<table>";
A[0] = new Array (1, "O ' nan", "male");
A[1] = new Array (2, "Little White Rabbit", "female");
A[2] = new Array (3, "Xiao Qi", "female");
for (var i = 0;i < A.length;i + +)
{
Temp = temp + "<tr>"
for (var j = 0;j < A[0].length;j + +)
{
Temp = temp + "<td>" + a[i][j] + "</td>";
}
Temp = temp + "</tr>"
}
Temp = temp + "</table>";
document.write (temp);
1.html
Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> storing data with arrays </title>
<body>
<script language= "JavaScript" type= "Text/javascript" src= "1.js" ></script>
</body>
Output of 1.html:
1 Ahanan Male
2 Little White Rabbit Girl
3 Little Kiki Girl
See the output, you may think we should start from that JS file, yes, we put the 1.html <script language= "JavaScript" type= "Text/javascript" src= "1.js" > </script>
Replace <script language= "JavaScript" type= "Text/javascript" src= "1.asp" ></script>
Save the 1.js as 1.asp and make the following modifications:
Copy Code code as follows:
var a = new Array ();
var temp = "<table>";
<%
Database connection code, opening connection
For i = 1 to 3
If objrs.eof Then Exit for
%>
A[<%=I%>] = new Array (<%=objrs (0)%>, "<%=objrs (1)%>", "<%=objrs (2)%>")
<%
Objrs.movenext
Next
%>
for (var i = 0;i < A.length;i + +)
{
Temp = temp + "<tr>"
for (var j = 0;j < A[0].length;j + +)
{
Temp = temp + "<td>" + a[i][j] + "</td>";
}
Temp = temp + "</tr>"
}
Temp = temp + "</table>";
document.write (temp);
ASP code Part I did not put out the complete code, only a little bit, please add yourself.