Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dealing with Forms
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dealing with Forms

 Post Reply Post Reply Page  12>
Author
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Topic: Dealing with Forms
    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?


Edited by xeerex - 04 April 2005 at 1:33pm
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2005 at 2:15pm
Originally posted by 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?

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post 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.LOL

Thanks for the feedback, and I'm certainly open to any more.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 05 April 2005 at 5:25am
You can do a for each item in form type loop, check the syntax on Google.
Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post 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.Smile


Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Posted: 05 April 2005 at 6:37pm
Originally posted by gullanian 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
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.