Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Multiple Similar Fields on a Form
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Multiple Similar Fields on a Form

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Multiple Similar Fields on a Form
    Posted: 27 September 2004 at 1:55am

I would like to develop a form that would have about 20 similar fields (ex: txtname_1, txtname_2, txtname_3,...). Then I would like to add the information to a database that would have the same EmailID. The UserID would be unique for each name. 

I don't want to have to use request.form 20 times to retrieve all of the names. I saw code that would allow you to do request.form on txtname_1 to txtname_20  with one line of code, but I cannot remember where I saw this code. Can someone please help me with this?

 

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 27 September 2004 at 4:56am
Dim I

For I = 1 to 20
    rs.Fields("txtName_" & i) = Request.Form("txtname_" & I)
Next

Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 29 September 2004 at 9:35pm

I have this part working now. But there's another problem. All of the fields might not be filled out. Only the first field is required. It will add blank information to the database with the new UserID and Email ID. I have a desire for the ASP Page to not add information to the database from the blank text boxes. How do I solve this problem?

Here's a copy of my code:

Dim I
For I = 1 to 20
Name = Request.Form("txtname_" & I)
Email = Request.Form("txtEmail_" & I)
rs2.AddNew
rs2("Name")= Name (Blank for every blank field name)
rs2("EmailAddr") = Email (Blank for every blank field name)

rs2("EmailID") = EmailNum
rs2.Update
Next

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 30 September 2004 at 12:51am
Try...

Dim I
For I = 1 to 20
Name = Request.Form("txtname_" & I)
Email = Request.Form("txtEmail_" & I) 

If Trim(Name) > "" then
   rs2.AddNew 
   rs2("Name")= Name (Blank for every blank field name)
  If Trim(EmailAddr) > "" then
        rs2("EmailAddr") = Email (Blank for every blank field name)
  End If

  rs2("EmailID") = EmailNum
  rs2.Update
End If

Next


Lead me not into temptation... I know the short cut, follow me.
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 30 September 2004 at 7:15pm

dpyers,

Thank you! The code worked. I used this for a web application that sends group emails. I am often notified when someone has read my email that was sent from the form. I think that you helped me to figure out the code for a web application that sent out individual emails before. This is a great resource because I like to know if my friends who have Yahoo or Hotmail email accounts read my emails or not.

 

Back to Top
 Post Reply Post Reply

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.