473,473 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

2 questions re asp email and forms

3 New Member
Apologies if these have already been posted, had a quick search but couldn't find anything.

Being a bit of a novice to web design I have 2 quick questions if you'd be so kind guys:-

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <table>
  4. <form action="testform.asp" method="post" >
  5. <tr><td colspan="2">
  6. <%    If FormErrorsString = " ConnectionError " Then 
  7.         response.write "<font color=red>There is currently a problem with connecting to the database. Please try again later.</font>"
  8.     Else 
  9.         response.write "Please enter your details here:"
  10.     End If 
  11. %></td>
  12. </tr>
  13.  
  14. <tr>
  15.     <td>Full Name:</td>
  16.     <td><%
  17.     If InStr(FormErrorsString, "$1$" ) Then 
  18.         'display image
  19.         Response.Write "<IMG SRC=""rejected.gif"" BORDER=""0"">"
  20.     End If 
  21.     %></td>
  22.     <td><input name="strname"  value="<%request("strname" )%> " SIZE=50> </td>    
  23.     <td><%
  24.     If InStr(FormErrorsString, "$1$" ) Then
  25.         'display image
  26.         Response.Write "<h5 style=""color:red"">There is an error in this field, please rectify and submit again</h5>"
  27.     End If
  28.     %></td>
  29. </tr>
  30.  
  31. ' ---------------------------
  32. ' Validation of script occurs
  33.  
  34. <%
  35. Function ConfirmationEmail()
  36.  
  37.     dim objemail
  38.     set objemail = Server.CreateObject("CDO.Message" )
  39.     objemail.From = "test_test@testwebsite" 
  40.     objemail.To = request("stremailadd" ) 
  41.     objemail.Cc = ";" & "nicholas.jones@xxxxxx.net" 
  42.     objemail.Subject = "test Confirmation"
  43.     objemail.HTMLBody = "Thank you for submitting your details regarding the xxxxxxx with us."
  44.     objemail.Send
  45.     set objemail = Nothing
  46.  
  47. End Function
  48. %>
  49.  
  50.  
The form is submitted to a database, once submitted I need it to send out an email to the person who has submitted (stremailadd) this works, I also however need to include in the same email the information the user submitted.

I've tried putting:-
objemail.HTMLBody = "Thank you for submitting your details regarding the xxxxxxx with us."
objemail.HTMLBody = request("strname" )
objemail.HTMLBody = request("stremailadd" )

etc....

But it doesn't seem to work, any pointers would be lovely.


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <tr>
  4.     <td>Email Address:</td>
  5.     <td><%
  6.     If InStr(FormErrorsString, "$2$" ) Then
  7.         'display image
  8.         Response.Write "<IMG SRC=""rejected.gif"" BORDER=""0"">"
  9.     End If
  10.     %></td>
  11.     <td><input name="stremailadd" value="<% If request("stremailadd" ) <> "" and InStr(request("stremailadd" ), "@xxxxx.net" ) >3 Then
  12.             response.write("stremailadd" )
  13.             End If %>@xxxxx.net" SIZE=50>
  14.     </td>
  15.  
  16.     <td><%
  17.     If InStr(FormErrorsString, "$2$" ) Then
  18.         'display image
  19.         Response.Write "<h5 style=""color:red"">There is an error in this field, please rectify and submit again</h5>"
  20.     End If
  21.     %></td>
  22.  
  23. </tr>
  24.  
  25.  
I also have set up the form so in the email address form field it permanently has "@xxxxx.net" in it, the problem comes that when I submit and the validation script runs I want it to put the users email address back in the form field without adding another "@xxxxx.net" I can't quite get it to work, at the moment it returns the form with "stremailadd@xxxxx.net" which obviously isn't right.
Again, I can't see what to change to make it return the users email address.

Thanks, I'm tearing my hair out now!
Nov 1 '07 #1
3 1482
markrawlingson
346 Recognized Expert Contributor
I've tried putting:-
objemail.HTMLBody = "Thank you for submitting your details regarding the xxxxxxx with us."
objemail.HTMLBody = request("strname" )
objemail.HTMLBody = request("stremailadd" )
The best way to do this is to set up a, usually, rather long variable.

Expand|Select|Wrap|Line Numbers
  1. sTemp = "Thank you for submitting your details regarding the xxxxxxx with us.<br/>"
  2. sTemp = sTemp & request("strname") & "<br/>"
  3. sTemp = sTemp & request("stremailadd") & "<br/>"
  4. objemail.HTMLBody = sTemp
  5.  
Second Question is because you put quotes around your response.write - so asp is interpretting this as you actually want to write "stremailadd", not the value of stremailadd

<td><input name="stremailadd" value="<% If request("stremailadd" ) <> "" and InStr(request("stremailadd" ), "@xxxxx.net" ) >3 Then
response.write("stremailadd" )
End If %>@xxxxx.net" SIZE=50>
Try this instead..

Expand|Select|Wrap|Line Numbers
  1. <td>
  2.    <input name="stremailadd" value="<% If request("stremailadd" ) <> "" and InStr(request("stremailadd"), "@xxxxx.net" ) >3 Then response.write stremailadd End If %>@xxxxx.net" SIZE=50>
  3.  
Hope this helps,

Sincerely,
Mark
Nov 2 '07 #2
nicjones
3 New Member
Thanks for the above post, much appreciated and very helpful.

In a similar vein to the above, I need to make a drop down box remember the inputs as well:-

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.     <td>Ready For Migration?</td>
  3.     <td><%
  4.     If InStr(FormErrorsString, "$6$") Then 
  5.         'display image
  6.         Response.Write "<IMG SRC=""rejected.gif"" BORDER=""0"">"
  7.     End If 
  8.     %></td>
  9.     <td><select class=black11 name="strreadymigrate" style="width:60">
  10.     <option value="">                         <option value="Yes">Yes                     <option value="No">No 
  11.     </select></td>
  12.     <td><%
  13.     If InStr(FormErrorsString, "$6$") Then
  14.         'display image
  15.         Response.Write "<p style=""color:red"">There is an error in this field, please rectify and submit again</p>"
  16.         End If
  17.     %></td>
  18. </tr>
  19.  
I've tried putting:-

<%If Trim(request("strreadymigrate")) = "Yes" Then
response.write "Yes"
End If %>

After each field but it doesn't seem to work, this is the only thing not working on the form now!


Help please!!
Nov 2 '07 #3
markrawlingson
346 Recognized Expert Contributor
Drop Down lists are set a default value by setting the option to "SELECTED".. see the below example..

Expand|Select|Wrap|Line Numbers
  1. <option value="Yes"  <% If Request.Form("thisdropdown") = "Yes" Then Response.Write "SELECTED" End If%>>Yes
  2. <option value="No" <% If Request.Form("thisdropdown") = "No" Then Response.Write "SELECTED" End If%>>No 
  3.  
Sincerely,
Mark
Nov 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Michael Hill | last post by:
This a valid call: document.myform.elements so is this: document.forms.elements but not this: document.forms.elements So, I have to iterate through the elements to find my field and make a...
1
by: Steven O. | last post by:
I am basically a hobbyist programmer, at the moment doing a little work experimenting with some AI stuff. I learned C++, and then tried to teach myself MFC using MS Visual C++ 6.0. I swore off of...
2
by: Matthew Clement | last post by:
I'm currently building a form (called frmReports) to set the criteria for a query, but I'm having some trouble with syntax and hope that one of the guru's here can help me achieve what I'm do. ...
2
by: David Ingram | last post by:
Greetings all! I am aiming to set up simple permissions for users on a database here at work, to the effect that certain users should be restricted from opening certain forms and reports. I...
4
by: Megan | last post by:
Okay, I have a few questions regarding an Access database our company has. I should first mention that I'm not that knowledgable in Access and don't really know how to use it, but I am learning. We...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
1
by: Russell | last post by:
Hi, I've been reading a lot about not using lookups in tables lately. Thus far, what I've been able to understand from my reading is this: - Do not use lookup fields in tables because they...
2
by: Mika M | last post by:
Hello! I'm using VB.NET 2003 and application type is Windows Forms. I have created into DataSet a table named as 'Teams' containing columns (fields) ID, Team, and Description. After that...
0
by: Kevin White | last post by:
I have a couple questions: 1- I have a question about using icons in my project. I have added an icon and have successfully used it for the notify icon, for forms in their title bar, and for...
2
by: kang jia | last post by:
hi currently, i am using Django to create webpage, in view.py the code is in the following: def contact(request): if request.method == 'POST': form =...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.