Forum Moderators: mack
Here is the form code:
<form method="get" action="submitsample.asp" id="frmWeblead_samples" name="form">
<td width="338">
<table cellpadding="2" cellspacing="0" style="table-layout:fixed;border: none;">
<col width="120px" />
<col width="220px" />
<tr>
<td><font color="#FF0000"><b>*</b></font>First Name:</td>
<td><input name="FirstName" id="FirstName" maxlength="32" class="inputbox" /></td>
</tr>
<tr>
<td><font color="#FF0000"><b>*</b></font>Last Name:</td>
<td><input name="LastName" id = "LastName" maxlength="32" class="inputbox" /></td>
</tr>
<tr>
<td><font color="#FF0000"><b>*</b></font>Company:</td>
<td><input name="CoName" id="CoName" maxlength="128" class="inputbox" /></td>
</tr>
<tr>
<td><font color="#FF0000"><b>*</b></font>Phone Number:</td>
<td><input name="Phone" id = "Phone" maxlength="32" class="inputbox" /></td>
</tr>
<tr>
<td><font color="#FF0000"><b>*</b></font>eMail Address:</td>
<td><input name="submit_by" id="submit_by" maxlength="128" class="inputbox" /></td>
</tr>
</table>
</td>
<td width="261">
<table cellpadding="2" cellspacing="0" style="table-layout:fixed;border: none;">
<col width="120px" />
<col width="220px" />
<tr>
<td width="111">Address 1:</td>
<td width="276"><input name="Address1" id="Address1"maxlength="64" class="inputbox" /></td>
</tr>
<tr>
<td>Address 2:</td>
<td><input name="Address2" maxlength="64" class="inputbox" /></td>
</tr>
<tr>
<td colspan="2">
<table cellpadding="0" cellspacing="0" style="table-layout:fixed;border: none;">
<col width="120px" />
<col width="100px" />
<col width="100px" />
<tr>
<td width="63">City/State:</td>
<td width="144"><input name="City" id="City" maxlength="32" class="inputboxsmall" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>Zip Code:</td>
<td><input name="zip code" id="zip code" maxlength="32" class="inputboxsmall" /></td>
</tr>
<tr>
<td>Country:</td>
<td><input name="Country" id="Country" maxlength="32" class="inputbox" /></td>
</tr>
</table></td>
</form>
</tr>
<tr>
<td>
<table width="410" border="0">
<tr>
<tr>
<td colspan="2"> </td>
</tr>
<td width="158">I would like samples of: </td>
<td width="119"><input type="checkbox" id="wipes" name="wipes" />
<label for="wipes">Wipes</label></td>
<td width="119"><input type="checkbox" id="gloveliners" name="gloveliners" />
<label for="gloveliners">Glove Liners </label></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" id="apparel" name="apparel" />
<label for="apparel">Apparel</label></td>
<td><input type="checkbox" id="esd" name="esd" />
<label for="esd">ESD</label></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" id="gloves" name="gloves" />
<label for="gloves">Gloves</label></td>
<td><input type="checkbox" id="documentation" name="documentation" />
<label for="documentation">Documentation</label></td>
</tr>
</table>
</td>
</tr>
<tr>
<tr>
<td colspan="2"> </td>
</tr>
<td colspan="2">
<table width="426" cellpadding="2" cellspacing="0" style="table-layout:fixed;border: none;">
<tr>
<td width="169">Occupation:</td>
<td width="238">
<select name="Occupation" id="Occupation">
<option value="none"></option>
<option value="Contamination Control Manager">Contamination Control Manager</option>
<option value="Microbiology" >Microbiology</option>
<option value="Lab Manager">Lab Manager </option>
<option value="Quality Control Manager">Quality Control Manager</option>
<option value="Production Management">Production Management</option>
<option value="Janitorial Supervisor">Janitorial Supervisor</option>
<option value="Facilities Maintenance">Facilities Maintenance</option>
<option value="Procurement Management">Procurement Management</option>
<option value="Environmental Safety">Environmental Safety</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td>Cleanroom classification:</td>
<td>
<select name="Cleanroom" id="Cleanroom">
<option value="none"></option>
<option value="ISO 3-4 (Class 1-10)">ISO 3-4 (Class 1-10)</option>
<option value="ISO 5-6 (Class 100-1,000)">ISO 5-6 (Class 100-1,000)</option>
<option value="ISO 7+ (Class 10,000+)">ISO 7+ (Class 10,000+)</option>
<option value="Industrial/Other">Industrial/Other</option>
<option value="Don't Know">Don't Know</option>
</select>
</td>
</tr>
<tr>
<td>Industry:</td>
<td>
<select name="Industry" id="Industry">
<option value="none"></option>
<option value="Microelectronics">Microelectronics</option>
<option value="Lifesciences/Pharmaceutical">Lifesciences/Pharmaceutical</option>
<option value="Biotechnology">Biotechnology </option>
<option value="Healthcare">Healthcare</option>
<option value="Aerospace/Defense">Aerospace/Defense</option>
<option value="Safety">Safety</option>
<option value="Electronics">Electronics </option>
<option value="Food Service">Food Services</option>
<option value="Automotive">Automotive</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td>How did you hear about us?</td>
<td>
<select name="HowdidUHear" id="HowdidUHear">
<option value="none"></option>
<option value="Friend/Colleague">Friend/Colleague</option>
<option value="Trade Show">Trade Show</option>
<option value="Salesperson">Salesperson</option>
<option value="AOL Search">AOL Search</option>
<option value="MSN Search">MSN Search</option>
<option value="Yahoo! Search">Yahoo! Search</option>
<option value="Google Search">Google Search </option>
<option value="Other">Other</option>
</select>
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" class="bottomborder"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td>Please let us know what specific samples you would like to receive: </td>
<td><textarea name="addtl" id="addtl" class="inputtextarea"></textarea></td>
</tr>
<tr>
<td colspan="2" class="bottomborder"> </td>
</tr>
<tr>
<td colspan="2" style="text-align:center;"> </td>
</tr>
<tr>
<td colspan="2" style="text-align:center;"><input name="button" type="button" class="formbutton" id="Submit1" onclick="verify();" value="Submit Request" />
<input type="reset" value="Reset" name="B2" class="formbutton" /></td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<p align="center">All information gathered is kept strictly confidential please see our <a href="http://example.com/ct/store/privacy.asp">privacy policy</a> for more information. </p>
<p align="center">
</td>
</tr>
</table>
</div></td>
</div>
</td>
</tr>
</table>
</form>
<!-- SCRIPT CONFIGURATION SECTION -->
<input type="HIDDEN" name="required" value="FirstName,LastName,submit_by,Phone,CoName"/>
<input type="HIDDEN" name="data_order" value="FirstName,LastName,submit_by,CoName,Address1,Address2,City,State,Zip,Phone"/>
<input type="HIDDEN" name="submit_to" value="kjohnson@example.com"/>
<input type="HIDDEN" name="automessage" value="http://example.com/cgi-bin/mymessage"/>
<input type="HIDDEN" name="outputfile" value="http://example.com/cgi-bin/form1"/>
<input type="HIDDEN" name="countfile" value="http://example.com/cgi-bin/form1"/>
<input type="HIDDEN" name="emailfile" value="http://example.com/cgi-bin/form1"/>
<input type="HIDDEN" name="ok_url" value="http://example.com/thanksGuide.asp"/>
<input type="HIDDEN" name="not_ok_url" value="http://example.com/sorryGuide.asp"/>
<!-- END OF SCRIPT CONFIGURATION SECTION -->
And here is my submitsamples.asp code:
<% language=VBScript %>
<%
Response.Buffer = True
Dim strBody 'Holds the body of the e-mail
Dim objJMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strSMTPServerAddress'Holds the SMTP Server address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress'Holds the return e-mail address of the user
strMyEmailAddress = "kjohnson@example.com "
strSMTPServerAddress = "127.0.0.1"
strCCEmailAddress = ""
strBCCEmailAddress = ""
strReturnEmailAddress = Request.Form("submit_by")
strBody = "FirstName: " & Request.Form("FirstName")&";" & vbCrLf & _
"LastName: " & Request.Form("LastName")&";" & vbCrLf & _
"Organization: " & Request.Form("CoName")&";" & vbCrLf & _
"Organization2: " & "" &";" & vbCrLf & _
"Address1: " & Request.Form("Address1")&";" & vbCrLf & _
"Address2: " & Request.Form("Address2")&";" & vbCrLf & _
"City/State: " & Request.Form("City")&";" & vbCrLf & _
"Country: " & Request.Form("Country") &";" & vbCrLf & _
"Zip/PostalCode: " & Request.Form("Zip")&";" & vbCrLf & _
"Telephone: " & Request.Form("Phone")&";" & vbCrLf & _
"Email: " & Request.Form("submit_by")&";" & vbCrLf & _
"Request: " & Request.Form("Request")&";" & vbCrLf & _
"Occupation: " & Request.Form("Occupation")&";" & vbCrLf & _
"Cleanroom Classsification: " & Request.Form("Cleanroom")&";" & vbCrLf & _
"Industry: " & Request.Form("Industry")&";" & vbCrLf & _
"No. of Operators: " & Request.Form("Operators")&";" & vbCrLf & _
"When do you plan on making a Purchase Decision: " & Request.Form("PurchaseDecision")&";" & vbCrLf & _
"How did you hear about us: " & Request.Form("Howdiduhear")&";" & vbCrLf & _
"I want to: " & vbCrLf
if (Request.Form("wipes") = "on") then strBody = strBody & " wipes"&"," & vbCrLf
if (Request.Form("apparel") = "on") then strBody = strBody & " apparel"&"," & vbCrLf
if (Request.Form("gloveliners") = "on") then strBody = strBody & " gloveliners"&"," & vbCrLf
if (Request.Form("gloves") = "on") then strBody = strBody & " gloves"&"," & vbCrLf
if (Request.Form("esd") = "on") then strBody = strBody & " esd"&"," & vbCrLf
if (Request.Form("documentation") = "on") then strBody = strBody & " documentation" &"," & vbCrLf
strBody = strBody&";"& vbCrLf & vbCrLf
strBody = strBody & " Please let us know what specific samples you would like to receive: " & Replace(Request.Form("addtl"), vbCrLf, "")&";"
'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail
Set oCdoMail = Server.CreateObject("CDO.Message")
Set oCdoConf = Server.CreateObject("CDO.Configuration")
sConfURL = "http://schemas.microsoft.com/cdo/configuration/"
with oCdoConf
.Fields.Item(sConfURL & "sendusing") =2
.Fields.Item(sConfURL & "smtpserver") = "127.0.0.1"
.Fields.Item(sConfURL & "smtpserverport") =25
.Fields.Update
end with
with oCdoMail
.From = strReturnEmailAddress
.To = strMyEmailAddress
.CC=strCCEmailAddress
.Subject = "Valutek Sample Request"
.TextBody = strBody
.HTMLBody = strBody
.Configuration = oCdoConf
.Send
end with
Set oCdoConf = Nothing
Set oCdoMail = Nothing
'Response.Write(strBody)
Response.Redirect "thanks.asp"
%>
[edited by: eelixduppy at 11:32 pm (utc) on Dec. 8, 2008]
[edit reason] exemplified [/edit]
I also can't get any of my check box options to show up in the email it sends.
<input type="checkbox" id="wipes" name="wipes" />
if (Request.Form("wipes") = "on") then strBody = strBody & " wipes" & "," & vbCrLf
if you were to re-code this part like so,
strBody & " my wipes value is " & Request.Form("wipes") & vbCrLf
What you would probably see is
my wipes value is
If it doesn't show as above, at least you would know what the actual value of Request.Form("wipes") is . . .
Is the light bulb coming on? :-) The checkbox has no value. Two possible fixes, IF the boxes are checked:
<input type="checkbox" id="wipes" name="wipes" value="on" />
or
<input type="checkbox" id="wipes" name="wipes" value="wipes" />
in combination with
if (Request.Form("wipes") = "wipes") then strBody = strBody & " wipes" & "," & vbCrLf
A more graceful solution would be to compose an array of the checkbox items and loop through it, if each value is submitted, output the text, but this should get you through.
Apologies to ASP coders for my rusty ASP . . .
Temporarily change the action of your form to test.asp.
Here is the sum total of the contents of test.asp:
<html>
<%
Response.Write "Starting form data:<br>";
' the preceding line is just so you know it is working
Dim vItem
For Each vItem In Request.Form
Response.Write " key: " & vItem & " value: " & Request.Form(vItem) & "<br>"
Next
%>
</html>
Review the resulting page very carefully. Make note of any keys that are not showing up, and any values that are blank.
Just a FYI, I can't remember if Windows servers respond to this, but on Linux (perl, php, etc.) a checkbox that isn't checked sends nothing. It doesn't exist. So the key for unchecked checkboxes shouldn't exist, but if they are checked, you should have a value.