VBScript traverses form elements to simplify data operation code

Source: Internet
Author: User
(ASP) traversing form elements to simplify data operation code

Function and description:
Most data operations are inseparable from forms. During update, a bunch of request. * and data fields must be listed.
Using traversal form elements saves a bunch of unnecessary things.

Msdn explains selectsinglenode.
Http://msdn2.microsoft.com/zh-cn/library/system.xml.xpath.xpathnavigator.selectsinglenode.aspx

1. Two methods to traverse form elements:
    Linenum

  1. Form
  2. 1. Traverse form elements
  3. Dim x' lists all elements in the form
  4. For x = 1 to request. Form. Count
  5. Response. Write Request. Form. Key (x )&"---"
  6. Response. Write Request. Form (x) & "<br/>"
  7. Next
  8. // Request. Form. Key (x) is the element name.
  9. // Request. Form (x) is the element value.
  10. 2. Traverse form elements-method 2
  11. Dim ELEM
  12. For each ELEM in request. Form
  13. Response. Write ELEM
  14. Response. Write Request (ELEM)
  15. Response. Write "<br/>"
  16. Next
  17. // ELEM is the element name.
  18. // Request. Form (ELEM) is the element value.

2. An example of operating XML data

    Linenum

  1. <%
  2. Dim hidchkvalue
  3. Hidchkvalue = request ("hidchkvalue ")
  4. Select case hidchkvalue
  5. Case "siteconfig"
  6. Set objxml = server. Createobject ("Microsoft. xmldom ")
  7. Objxml. Load (server. mappath ("include/system/config. xml "))
  8. For each ELEM in request. Form
  9. If instr (ELEM, "Site") <> 0 then
  10. Temp = request (ELEM)
  11. If temp = "" Then temp = ELEM & "undefined"
  12. Objxml. selectsinglenode ("//" & ELEM). Text = temp
  13. End if
  14. Next
  15. Objxml. Save server. mappath ("include/system/config. xml ")
  16. Set objxml = nothing
  17. Response. Write pmtreturn
  18. End select
  19. %>


 

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.