Code for using arrays to store data under ASP-application Tips

Source: Internet
Author: User
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[&LT;%=I%&GT] = 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.
Related Article

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.