Service-side VBScript and JScript several of the same characteristics

Source: Internet
Author: User
Tags object chr eval include variables variable

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 transformation of the value of variables, 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 file

3.1 VBScript dynamic Include files

3.2 JScript dynamic Include files

The following are the referenced contents:

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 transformation of the value of variables, 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 file
3.1 VBScript dynamic Include files

LineNum
<%
  function finclude (filepath)
  ' Sample call '///Execute finclude ("Include/sys tem/language/"&sitefglang&"/main.asp ") \\\ '"
      Dim cnt
           cnt=createobject ("Scripting.FileSystemObject"). OpenTextFile ( Server. MapPath (filepath)). ReadAll
          cnt=replace (CNT, "<" &CHR (Panax Notoginseng), "")
          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 file

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.