Skip to content Skip to sidebar Skip to footer

Requesting Field Names And Values From Form And Add Them On The Fly In A Script

Hi I have a form and the action is submitting into a script named autoform.asp. In this script I usually request the fields values like this: txtFirstName = Request.Form('txtFirstn

Solution 1:

EDIT as per comment below

You can use the Execute statement to mimic import_request_variables from php

ForEach Item In Request.Form
   ItemValue = Request.Form(Item)
   Execute Item & " = """ & ItemValue & """"
Next

If you are intending to output

Firstname = Request.Form("Firstname")

then use

<%
ForEach Item In Request.Form
   fieldName = Item
   fieldValue = Request.Form(Item) 
   Response.Write(fieldName & " = Request.Form(""" & fieldName & """)")
Next
%>

If you are intending to output

Firstname = "John"

then use

<%
ForEach Item In Request.Form
  fieldName = Item
  fieldValue = Request.Form(Item) 
  Response.Write(fieldName & " = """ & fieldValue & """")
Next
%>

Post a Comment for "Requesting Field Names And Values From Form And Add Them On The Fly In A Script"