Js|jscript|vbscript
Service-side VBScript and JScript several of the same characteristics
Absrtact: This article demonstrates several important applications of ASP server-side scripting.
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, "<" &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 Inclusion text
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;
}
%>