A few of the same features of service-side VBScript and JScript are written and examples _ Application techniques

Source: Internet
Author: User
Tags chr eval
by Shawl.qiu
Summary:
This article demonstrates several important applications of ASP server-side scripting.

Directory:
1. Traverse the collection/object
1.1 VBScript traverse a collection of forms
1.2 JScript Traverse Form Collection

2. The conversion value is variable and assigned
2.1 VBScript Transition measure value is variable and assigned value
2.2 JScript Transition measure value is variable and assign value

3. Dynamic Include files
3.1 VBScript dynamic Include files
3.2 JScript dynamic Include files

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

1. Traverse the collection/object
1.1 VBScript traverse a collection of forms

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

1.2 JScript Traverse Form Collection

LineNum
<%
for (Var $e =new Enumerator (request.form);! $e. AtEnd (); $e. MoveNext ()) {
Response.Write ($e. Item () + ':<br/> ' +request.form ($e. Item ()));
}
%>

2. The conversion value is variable and assigned
2.1 VBScript Transition measure value is variable and assigned value

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

2.2 JScript Transition measure value is variable and assign value

LineNum
<%
var $xml =new ActiveXObject ("Microsoft.XMLDOM");
$xml. Load (Server.MapPath (' Config.xml '));
var $childNodes = $xml. Documentelement.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. Dynamic Include files
3.1 VBScript dynamic Include files

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, "<" &AMP;CHR (37), "")
Cnt=replace (CNT,CHR (Panax) & ">", "")
Finclude=cnt
End Function ' Shawl.qiu code '
Execute Finclude ("include/system/language/" &sitefglang& "/main.asp")
%>

3.2 JScript dynamic Include files

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

function $dynInc ($FL) {
/* ------------------------------------\
* Server-side JScript dynamic include 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;
}
%>

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.