Writing Byshawl. qiu _ basic knowledge about several similar features of server VBScript and JScript

Source: Internet
Author: User
Byshawl. qiu Abstract:
This article demonstrates several important applications of ASP server scripts.

Directory:
1. Traverse collection/Object
1.1 VBScript traversal form set
1.2 JScript traversal form set

2. Convert the value to a variable and assign a value to it.
2.1 VBScript convert a value to a variable and assign a value
2.2 JScript convert a value to a variable and assign a value

3. dynamically include files
3.1 VBScript dynamic File Inclusion
3.2 JScript dynamic File Inclusion

Shawl. qiu
2006-10-11
Http://blog.csdn.net/btbtd

1. Traverse collection/Object
1.1 VBScript traversal form set

Linenum
<%
For each temp in request. Form
Response. write temp & ":" & request. form (temp)
Next
%>

1.2 JScript traversal form set

Linenum
<%
For (var $ e = new Enumerator (Request. Form );! $ E. atEnd (); $ e. moveNext ()){
Response. Write ($ e. item () + ':
'+ Request. Form ($ e. item ()));
}
%>

2. Convert the value to a variable and assign a value to it.
2.1 VBScript convert a value to a variable and assign a value

Linenum
<%
For each temp in request. Form
Execute temp & "= request. form (temp )"
Next
%>

2.2 JScript convert a value to a variable and assign a value

Linenum
<%
Var $ xml = new ActiveXObject ("microsoft. xmldom ");
$ Xml. load (Server. MapPath ('config. xml '));
Var using childnodesusing using xml.doc umentElement. selectSingleNode ('// siteconfig'). childNodes

For ($ e = new Enumerator ($ childNodes );! $ E. atEnd (); $ e. moveNext ()){
Eval ($ e. item (). nodeName + "= $ e. item (). text ");
}
$ Xml = null;
Response. Write (sitekeywords );
%>

3. dynamically include files
3.1 VBScript dynamic File Inclusion

Linenum
<%
Function fInclude (filepath)
'Sample call''' // execute fInclude ("include/system/language/" & sitefglang & "/main. asp ")\\\'''
Dim cnt
Cnt = CreateObject ("scripting. fileSystemObject"). openTextFile (server. MapPath (filepath). readall
Cnt = replace (cnt, "<" & chr (37 ),"")
Cnt = replace (cnt, chr (37) & "> ","")
FInclude = cnt
End function 'awl. qiu Code'
Execute fInclude ("include/system/language/" & sitefglang & "/main. asp ")
%>

3.2 JScript dynamic File Inclusion

Linenum
<%
Eval ($ dynInc ('aj2. asp '));
Response. Write ($ test );

Function $ dynInc ($ fl ){
/*------------------------------------\
* The JScript on the server dynamically contains the file By shawl. qiu
* Sample call: eval ($ dynInc ('aj2. asp '));
\*------------------------------------*/
Var $ fso = new ActiveXObject ("scripting. fileSystemObject ");
$ Str = $ fso. OpenTextFile (Server. MapPath ($ fl). ReadAll ();
$ Str = $ str. replace (/\<\%|\%\>/g ,'');
$ Fso = null;
Return $ str;
}
%>
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.