VB icon

Dynamic Form Field Capture

Email
Submitted on: 1/6/2015 7:06:00 PM
By: Scott King (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: HTML, VbScript (browser/client side)
Views: 789
 
     This code will caputre all fields in an HTML form and create a template for a VBScript function that passes the fields to a stored procedure.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Dynamic Form Field Capture
' Description:This code will caputre all fields in an HTML form and create a template for a VBScript function that passes the fields to a stored procedure.
' By: Scott King (from psc cd)
'
' Assumes:To use this file: Set the action on your form to point to this file. 
You will then get a formatted list to process your form in VBScript and 
a matching SQL Stored Procedure field list. Ex: action="get_fields.asp" target=_blank <br>
Warning: You should have your form fields named the same as your database
fields or this script won't really work for you... Have Fun!
'**************************************

<%@Language="VBScript"%>
<!--
	Created By: J. Scott King 4/28/2003
	Purpose: To make it easier for one to get form fields from an HTML form and turn
	them into scripting objects. Thus making a "plug and play" type interface for
	creating SQL stored procedures.
	Contact: jscott38@cox.net
-->
<title>Dynamic Form Field Creation</title>
To use this file: Set the action on your form to point to this file. 
You will then get a formatted list to process your form in VBScript and 
a matching SQL Stored Procedure field list. Ex: action="get_fields.asp" target=_blank <br>
Warning: You should have your form fields named the same as your database
fields or this script won't really work for you... Have Fun!
<hr>
<table width=100% cellspacing=1 bgcolor=Gainsboro>
<tr>
 <td colspan=2>
	<b>VBScript Form Fields.....</b>
	<textarea name=vbform rows=10 cols=110>
	<%
	For i = 1 to Request.Form.Count
	fieldName = Request.Form.Key(i)
	fieldValue = Request.Form.Item(i) 
	If i Mod 3 = 0 then
			Response.Write(" Request.Form(""& fieldName& "") & "','" & _ "&vbCrLf)
	Else
			Response.Write(" Request.Form(""& fieldName& "") & "','" &")
		End If
	Next
	%>
	</textarea>
 </td>
</tr>
<tr>
 <td>
	<b>SQL Stored Procedure Fields.....</b>
	<textarea name=spfields rows=20 cols=40>
	<%
	For ix = 1 to Request.Form.Count
	fieldName = Request.Form.Key(ix)
	fieldValue = Request.Form.Item(ix) 
	Response.Write("@"&fieldName&" varchar(50),"&vbCrLf)
	Next
	%>
	</textarea>
 </td>
 <td>
	<b>SQL Stored Procedure Update Fields.....</b>
	<textarea name=spupdate rows=20 cols=40>
		<%
		For ix = 1 to Request.Form.Count
		fieldName = Request.Form.Key(ix)
		fieldValue = Request.Form.Item(ix) 
		Response.Write(fieldname & " = @"&fieldName&","&vbCrLf)
		Next
		%>
	</textarea>
 </td>
</tr>
</table>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.