Dealing with Forms
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14553
Printed Date: 30 March 2026 at 6:55am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Dealing with Forms
Posted By: xeerex
Subject: Dealing with Forms
Date Posted: 04 April 2005 at 1:32pm
Hi all,
I have a client with a form page that contains a lot of entries. Now I
can pass the form along and have the script email or write to values to
a database. My issue is dealing with all the code such as:
<%
'Input from Form 1
strForm1 = Request.From("Input1")
strForm2 = Request.From("Input2")
strForm3 = Request.From("Input3")
strForm4 = Request.From("Input4")
'Input from Form 2
strForm21 = Request.From("Input21")
strForm22 = Request.From("Input22")
strForm23 = Request.From("Input23")
strForm24 = Request.From("Input24")
%>
|
For instance, I want a single "sendmail" page that I can use with
nearly all my form pages. What is the best way to deal with all the
form data? What suggestions do you have?
------------- http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production
|
Replies:
Posted By: dj air
Date Posted: 04 April 2005 at 1:40pm
you could send a field entry called "FormID" and when submitted the formID is checked and uses the relavent requests.
do an elseif statement on the FormID
i take it this is what you mean.
would the above code be on the send form page?
if so the above i have spoke about might be the best way.
i have a script witin the shopping cart im making, that allows me to
send details from one sever to another and for each item it is given an
ID and that ID is stored in a form element and is split on the other
server to get the details.
of course you dont need to split but you could send a formID
|
Posted By: xeerex
Date Posted: 04 April 2005 at 2:15pm
wrote:
would the above code be on the send form page? |
Yep -- I should have clarified that.
MyForm.asp (simplified code for example)
<form name="form1" method="post" action="SendMail.asp">
<input type="text" name="textfield1">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<select name="select1">
<option value="Choice1">Choice1</option>
<option value="Choice2">Choice2</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
|
SendMail.asp (code snippets simplified for example)
strtextfield1 = Request.Form("textfield")
strtextfield2 = Request.Form("textfield2")
strtextfield2 = Request.Form("textfield2")
strSelect1 = Request.Form("select1")
strEmailBody = "Information: </br>"
If strtextfield1 <> "" Then
strEmailBody = strEmailBody & "Field 1: " & strtextfield1"
End If
~~remaining if statements~~
~~sendmail script here~~~
|
So the question is: Is there an easier way rather than "If Then" for everything?
------------- http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production
|
Posted By: dj air
Date Posted: 04 April 2005 at 2:54pm
the only way really is to have standard form names i thikn
formelement1
formelement2
etc
bu then it depends what the output to the email is.. if its just a set of values then that would be ok.
but if its like the forum emails then if's i think are the only option.
|
Posted By: xeerex
Date Posted: 04 April 2005 at 9:36pm
Yeah -- I thought so. Sometimes it helps to just "vent frustrations"
and have someone else reassure you. This is one of those projects that
was decent money, but the little things are consuming time.
Thanks for the feedback, and I'm certainly open to any more.
------------- http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production
|
Posted By: Gullanian
Date Posted: 05 April 2005 at 5:25am
|
You can do a for each item in form type loop, check the syntax on Google.
|
Posted By: xeerex
Date Posted: 05 April 2005 at 5:39pm
I'll research that and see.
As a side note, I've also discovered a very good use for the "Forms
--> View Forms Information" button on the WebDeveloper extension in
Firefox. It prints out each item in the form page and makes a good way
to visually double-check naming consistency etc.

------------- http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production
|
Posted By: xeerex
Date Posted: 05 April 2005 at 6:37pm
gullanian wrote:
You can do a for each item in form type loop, check the syntax on Google.
|
Thanks a ton! I had forgotten who is every geeks friend? --> Google,
but your suggestion of a for..next loop was right on target!
For anyone else looking, here is a great page on how to manipulate complex form data with ease:
http://www.devx.com/asp/Article/17745/1763/page/1 - http://www.devx.com/asp/Article/17745/1763/page/1
------------- http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production
|
Posted By: Gullanian
Date Posted: 06 April 2005 at 10:20am
No problemo
|
|