PDA

View Full Version : Form email problem



jaybird84404
06 Nov 2009, 04:40 PM
I created a form that is emailed through obj.CDO. The problem is that is a part of the form changes based on a previous answer and I wasn't sure how to capture only the relevant information, so in the email it would inclue blank spaces for stuff related to home address when the person chose to pick the item up at the store, etc. I have tried putting different if statements in to try and only get it to give me the relevant information after the shipping method, but now I can't get it to email anything to me at all.

Here is the code that works but sends me the blank lines for unnecessary fields:

<html>
<head>
<title>Congratulations</title>
<script>
function ShowMenu(num, menu, max)
{
//num is selected value, menu is the name of the div, max is the number of divs
for(i = 1; i <= max; i++){
//add number onto end of menu
var menu_div = menu + i;

//if current show
if(i == num) {
document.getElementById(menu_div).style.display = 'block';
} else {
//if not, hide
document.getElementById(menu_div).style.display = 'none';
}
}



}
</script>

<%
if Request.Form("isSubmitted") = "yes" then
Dim Name, Email, Phone, Item, officenumber, mailcode, street, city, state, zipcode
name = Request.Form("Name")
email = Request.Form ("Email")
phone = Request.Form("Phone")
item = Request.Form("Item")
officenumber = Request.Form("officenumber")
mailcode = Request.Form("mailcode")
street = Request.Form("street")
city = Request.Form("city")
state = Request.Form("state")
zipcode = Request.Form("zipcode")

Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "bookstore@weber.edu"
objCDO.To = "serviceaward@weber.edu"
objCDO.Subject = "Service Award Order"
objCDO.Body = "Name: " & Name & vbcrlf&_
"Email Address: " & Email & vbcrlf&_
"Phone: " & Phone & vbcrlf&_
"Item: " & Item & vbcrlf&_
"Office Number: " & officenumber & vbcrlf&_
"Mail Code: " & mailcode & vbcrlf&_
"Street: " & street & vbcrlf&_
"City: " & city & vbcrlf&_
"State: " & state & vbcrlf&_
"Zip Code: " & zipcode
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

ConfirmMsg = "Thank you for submitting your order!"
end if
%>

<%
if Request.Form("isSubmitted") = "yes" then
Response.Redirect "http://bookstore.weber.edu/thanks.asp"
end if
%>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-image: url(images/Years%20of%20Service%20-%20Web%20OrderPage.jpg);
background-repeat: no-repeat;
}
-->
</style></head>

<br/><br/><br/><br/><br/><br/><br/>
<% if ConfirmMsg <> "" then %>

<h2><%= ConfirmMsg %></h2>

<% end if %>

<form action="/jaystest.asp" method="post">
<p>Name (First & Last): <input name="Name" type="text" size="20">
<br>
Email Address: <input name="Email" type="text" size="26"><br>
Phone Extension: <input name="Phone" size="24" tpye="text"><br>
Gift Item #: <input name="Item" size="30" tpye="text"><br><br>
Select your preferred method of delivery:
<br>
<select id='deliverymethod'
onChange="javascript: ShowMenu(document.getElementById('deliverymethod').value,'divColor', 6);">
<option value='0'>Please select one
<option value='1'>Pick-up at bookstore
<option value='2'>Deliver to my office
<option value='3'>Deliver to my home

</select>
</p>
<div id='divColor1' style="display: none;">

</div>

<div id='divColor2' style="display: none;">
<br>Office Number: <input name="officenumber" type="text" value="" size="5"><br>
Mail Code: <input name="mailcode" type="text" value="" size="9"><br>
</div>

<div id='divColor3' style="display: none;">
<br>Street Address: <input name="street" type="text" value="" size="22"><br>
City: <input type="text" name="city" value="">
State: <input name="state" type="text" value="" size="2" maxlength="2"><br>
Zip Code: <input name="zipcode" type="text" value="" size="5" maxlength="5"><br>
</div>
<input name="isSubmitted" type="hidden" value="yes">
<br><br>
<input type="submit" value="Submit Form">
</form>

</body>
</html>





Here is the code that I currently have where I tried putting some if statements int here, but now I am not getting any emails. As you can see, I have several different methods in there, but none of them are working.


<html>
<head>
<title>Congratulations</title>

<script>
function ShowMenu(num, menu, max)
{
//num is selected value, menu is the name of the div, max is the number of divs
for(i = 1; i <= max; i++){
//add number onto end of menu
var menu_div = menu + i;

//if current show
if(i == num) {
document.getElementById(menu_div).style.display = 'block';
} else {
//if not, hide
document.getElementById(menu_div).style.display = 'none';
}
}



}
</script>
<%
if Request.Form("isSubmitted") = "yes" then
Dim Name, Email, Phone, Item, officenumber, mailcode, street, city, state, zipcode
name = Request.Form("Name")
email = Request.Form ("Email")
phone = Request.Form("Phone")
item = Request.Form("Item")
officenumber = Request.Form("officenumber")
mailcode = Request.Form("mailcode")
street = Request.Form("street")
city = Request.Form("city")
state = Request.Form("state")
zipcode = Request.Form("zipcode")
end if %>

<% if divColor = "1" Then
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "bookstore@weber.edu"
objCDO.To = "jaymitchell@weber.edu"
objCDO.Subject = "Service Award Order"
objCDO.Body = "Name: " & Name & vbcrlf&_
"Email Address: " & Email & vbcrlf&_
"Phone: " & Phone & vbcrlf&_
"Item: " & Item & vbcrlf&_
"Delivery Method: Pick up at bookstore"
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

ConfirmMsg = "Thank you for submitting your order!"
end if %>


<% if deliverymethod = "2" Then
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "bookstore@weber.edu"
objCDO.To = "jaymitchell@weber.edu"
objCDO.Subject = "Service Award Order"
objCDO.Body = "Name: " & Name & vbcrlf&_
"Email Address: " & Email & vbcrlf&_
"Phone: " & Phone & vbcrlf&_
"Item: " & Item & vbcrlf&_
"Delivery Method: Deliver to my office" & vbcrlf&_
"Office Number: " & officenumber & vbcrlf&_
"Mail Code: " & mailcode
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

ConfirmMsg = "Thank you for submitting your order!"
end if %>

<% if Request.Form("divColor") = "3" Then
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "bookstore@weber.edu"
objCDO.To = "jaymitchell@weber.edu"
objCDO.Subject = "Service Award Order"
objCDO.Body = "Name: " & Name & vbcrlf&_
"Email Address: " & Email & vbcrlf&_
"Phone: " & Phone & vbcrlf&_
"Item: " & Item & vbcrlf&_
"Delivery Method: Delivery to my home" & vbcrlf&_
"Street: " & street & vbcrlf&_
"City: " & city & vbcrlf&_
"State: " & state & vbcrlf&_
"Zip Code: " & zipcode
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

ConfirmMsg = "Thank you for submitting your order!"
end if %>


<%
if Request.Form("isSubmitted") = "yes" then
Response.Redirect "http://bookstore.weber.edu/thanks.asp"
end if
%>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-image: url(images/Years%20of%20Service%20-%20Web%20OrderPage.jpg);
background-repeat: no-repeat;
}
-->
</style></head>

<br/><br/><br/><br/><br/><br/><br/>
<% if ConfirmMsg <> "" then %>

<h2><%= ConfirmMsg %></h2>

<% end if %>

<form action="/jaystest.asp" method="post">
<p>Name (First & Last): <input name="Name" type="text" size="20">
<br>
Email Address: <input name="Email" type="text" size="26"><br>
Phone Extension: <input name="Phone" size="24" tpye="text"><br>
Gift Item #: <input name="Item" size="30" tpye="text"><br><br>
Select your preferred method of delivery:
<br>
<select id='deliverymethod'
onChange="javascript: ShowMenu(document.getElementById('deliverymethod').value,'divColor', 6);">
<option value='0'>Please select one
<option value='1'>Pick-up at bookstore
<option value='2'>Deliver to my office
<option value='3'>Deliver to my home

</select>
</p>
<div id='divColor1' style="display: none;">

</div>

<div id='divColor2' style="display: none;">
<br>Office Number: <input name="officenumber" type="text" value="" size="5"><br>
Mail Code: <input name="mailcode" type="text" value="" size="9"><br>
</div>

<div id='divColor3' style="display: none;">
<br>Street Address: <input name="street" type="text" value="" size="22"><br>
City: <input type="text" name="city" value="">
State: <input name="state" type="text" value="" size="2" maxlength="2"><br>
Zip Code: <input name="zipcode" type="text" value="" size="5" maxlength="5"><br>
</div>
<input name="isSubmitted" type="hidden" value="yes">
<br><br>
<input type="submit" value="Submit Form">
</form>
</body>
</html>

Any ideas?