All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
subroutine,creates,variable,each,form,item,fo
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,252. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Web Online Examination
By Suhas Manjunath Kashyap on 11/7


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

VarsFromForm

Print
Email
 
VB icon
Submitted on: 7/20/2000 5:56:43 PM
By: Dean Kroon 
Level: Intermediate
User Rating: By 8 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 14885 times.
 
 
     This subroutine creates a variable (on the fly) for each form item found on Request.Forms or Request.QueryString collections. The variable is given the same name as the form items name. It was built to duplicate some of PHPs built in functionality.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: VarsFromForm
    ' Description:This subroutine creates a 
    '     variable (on the fly) for each form item
    '     found on Request.Forms or Request.QueryS
    '     tring collections. The variable is given
    '     the same name as the form items name. It
    '     was built to duplicate some of PHPs buil
    '     t in functionality. 
    ' By: Dean Kroon
    '
    ' Assumes:
    Ex.
    ' this form lives in some asp or html pa
    '     ge
    <FORM method="post" action="doit.asp">
    <INPUT type="text" name="name">
    <INPUT type="text" name="Address1">
    <INPUT type="text" name="Address2">
    </FORM>
    ' the user enters:
    Dean Kroon
    421 Blue Earth St
    PO Box 123
    ' this code lives in doit.asp
    <%
    Call VarsFromForm
    Response.write name & "<BR>" & address1 & ", " & address2
    %>
    ' The output looks like
    Dean Kroon
    421 Blue Earth St, PO Box 123
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6278&lngWId=4    'for details.    '**************************************
    
    Public Sub VarsFromForm
    	For Each item In request.form
    		execute(item & "=""" & Replace(request.form(item), Chr(34), Chr(34) & Chr(34)) & """")
    	Next
    	For Each item In request.QueryString
    		execute(item & "=""" & Replace(request.QueryString(item), Chr(34), Chr(34) & Chr(34)) & """")
    	Next
    End Sub

 
 Report Bad Submission
Use this form to notify 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 Intermediate 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
10/6/2000 10:37:22 AMShawn Elliott

This is excellent. I give it a 'Excellent' Vote. I was working on an online "Dynamic" item calculator. Thus I wouldn't know how many items there would be in the Forms Collection nor their names. Only a certain naming convention. Thanks.

(If this comment was disrespectful, please report it.)

 
8/29/2001 10:01:50 AMTarran Walker

I was looking around on the net to find a generic reuseable
(If this comment was disrespectful, please report it.)

 
4/29/2002 11:09:07 AMGeorge

I desperately want to use your code (VARSFROMFORM) but have absolutly no idea where to put the code in my HTML form. Any ideas please ?
Is it ANYWHERE, AT THE TOP, AT THE BOTTOM, IN THE MIDDLE, OR does it have a place. Sorry, but ASP is as clear to me as Chinese was to you before you studied it.
I have my form but can't send it here as it is in html and it will garble.

Your assistance is greatly appreciated.
(If this comment was disrespectful, please report it.)

 
12/3/2002 4:40:36 PM

this code is great I have modified it to trap for single quotes as well. But if you are catching a hard return from a text area this code will through an "unterminated string constant" error. I have tried many thing to correct this but fail every time. Any Idea's? here is an extra replace to trap for ' quotes.for each item in request.form formdata=formdata & "&" & item & "=" & request.form(item) 'trap for hard returns execute(item & "=""" & Replace(Replace(Replace(request.form(item), Chr(34),chr(34) & chr(34)),chr(13), "
"),chr(39),"´") & """") response.write(item & "=""" & Replace(Replace(request.form(item), Chr(39), "´"),chr(13), "
") & """") & "
" next formdata = a variable to be passed back to rewrite the form in the event of an error.
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.