Help looping through form fields and displaying only values with data

Discussion in 'C#' started by qman107, Jan 24, 2008.

  1. #1
    I am passing form fields to an ASP page via post from a HTML page.
    The form on the HTML page is huge and contains about 100 form fields.

    I want to iterate through the form fields via ASP ONLY retreiving the fields that contain actual values. Below is my code, which currently retreives ALL form fields from the passed HTML form (except for name, preview.x, and preview.y).

    <%
    'iterate through each form field from passed html form, exclude specific fields shown below
    Dim fldName
    For Each fldName in Request.Form
    if (fldName <> "preview.x") AND (fldName <> "preview.y") AND (fldName <> "name") AND _
    (fldName <> "ext") AND (fldName <> "dept") AND (fldName <> "date") then
    Response.Write fldName & ": " & _
    Request.Form(fldName) & "<br />"
    end if
    Next
    %>


    Thanks very much!
     
    qman107, Jan 24, 2008 IP
  2. MarkusJ_NZ

    MarkusJ_NZ Well-Known Member

    Messages:
    240
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Try
    ...
    if len(Request.Form(fldName)) > 0 then
    Response.Write fldName & ": " & _
    Request.Form(fldName) & "<br />"
    end if
    ...
     
    MarkusJ_NZ, Jan 31, 2008 IP