Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus that are SELECT elements (javascript-- one named arrivalcity and one named returncity). Basically they ask for a departure and return city and another menu appears with options based on that city. I can't seem to get the input from these fields in the vbscript. I'm guessing you have to code it a different way. I can get all the other menu fields, but not these two. Any help will be greatly appreciated. Also, I think I read something that with a select element the return will be both fields together. Is this true.
The form is at the following URL:
The VBscript is the following (I know it's long, but I'll put it here if anybody wants to take a look at it).
The form is at the following URL:
The VBscript is the following (I know it's long, but I'll put it here if anybody wants to take a look at it).
Code:
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Eurofly Vacations Car Rental Booking Form</title>
<link href="/includes/style_home.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {background-color: #ffffff;}
.bodyfont {color: #FF0000; font-family: Arial; font-size: 13px; font-weight: normal}
.otherfont {color: #000000; font-family: Arial; font-size: 13px; font-weight: bold}
</style>
</head>
<body>
<table width="675" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="100"><a href="http://euroflyvacations.com"><img src="img/logo_eurofly.jpg" border="0"></a><br>
<br></td>
</tr>
<tr>
<td>
<%@LANGUAGE="VBSCRIPT"%>
<%
flag = 0
errmsg = ""
agencyname = Trim(Request.Form("agencyname"))
iata = Trim(Request.Form("iata"))
address = Trim(Request.Form("address"))
citystatezip = Trim(Request.Form("citystatezip"))
contactname = Trim(Request.Form("contactname"))
phone = Trim(Request.Form("phone"))
fax = Trim(Request.Form("fax"))
email = Trim(Request.Form("email"))
passenger1first = Trim(Request.Form("passenger1first"))
passenger1last = Trim(Request.Form("passenger1last"))
passenger2first = Trim(Request.Form("passenger2first"))
passenger2last = Trim(Request.Form("passenger2last"))
passenger3first = Trim(Request.Form("passenger3first"))
passenger3last = Trim(Request.Form("passenger3last"))
passenger4first = Trim(Request.Form("passenger4first"))
passenger4last = Trim(Request.Form("passenger4last"))
arrivalcity = Trim(Request.Form("arrivalcity"))
departuredate_Rome = Trim(Request.Form("arrival_select1"))
departuredate_Naples = Trim(Request.Form("arrival_select2"))
departuredate_Palermo = Trim(Request.Form("arrival_select3"))
departuredate_Catania = Trim(Request.Form("arrival_select4"))
departuredate_Other = Trim(Request.Form("arrival_select5"))
returncity = Trim(Request.Form("returncity"))
returndate_Rome = Trim(Request.Form("return7"))
returndate_Naples = Trim(Request.Form("return8"))
returndate_Palermo = Trim(Request.Form("return9"))
returndate_Catania = Trim(Request.Form("return10"))
returndate_Other = Trim(Request.Form("return11"))
business = Trim(Request.Form("business"))
pickuplocation = Trim(Request.Form("pickuplocation"))
dropofflocation = Trim(Request.Form("dropofflocation"))
cartype = Trim(Request.Form("cartype"))
carupgrade = Trim(Request.Form("carupgrade"))
extension = Trim(Request.Form("extension"))
extras = Trim(Request.Form("extras"))
insurance = Trim(Request.Form("insurance"))
if agencyname = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply the Agency Name</span><br>"
flag = flag +1
end if
if len(iata) < 8 then
errmsg = errmsg & "<span class=bodyfont> - You must supply a valid IATA number</span><br>"
flag = flag +1
end if
if contactname = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a valid contact name for your agency</span><br>"
flag = flag +1
end if
if address = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a valid address for your agency</span><br>"
flag = flag +1
end if
if citystatezip = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a valid City, State and Zip Code for your agency</span><br>"
flag = flag +1
end if
if len(phone) < 10 then
errmsg = errmsg & "<span class=bodyfont> - You must supply a contact phone number for this request</span><br>"
flag = flag +1
end if
if email = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a contact email address for this request</span><br>"
flag = flag +1
else
if isValidEmail(email) = "False" then
errmsg = errmsg & "<span class=bodyfont> - A proper formatted Email 'name@company.com' </span><br>"
flag = flag +1
end if
end if
if passenger1first = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply the first name of Passenger 1</span><br>"
flag = flag +1
end if
if passenger1last = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply the last name of Passenger 1</span><br>"
flag = flag +1
end if
if arrivalcity = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a departure city for this request</span><br>"
flag = flag +1
elseif arrivalcity = "1" and arrival_select1 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a departure date for this request</span><br>"
flag = flag +1
elseif arrivalcity = "2" and arrival_select2 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a departure date for this request</span><br>"
flag = flag +1
elseif arrivalcity = "3" and arrival_select3 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a departure date for this request</span><br>"
flag = flag +1
elseif arrivalcity = "4" and arrival_select4 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a departure date for this request</span><br>"
flag = flag +1
elseif arrivalcity = "5" and arrival_select5 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply an departure date for this request</span><br>"
flag = flag +1
end if
if returncity = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return city for this request</span><br>"
flag = flag +1
elseif returncity = "1" and return1 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return date for this request</span><br>"
flag = flag +1
elseif returncity = "2" and return2 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return date for this request</span><br>"
flag = flag +1
elseif returncity = "3" and return3 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return date for this request</span><br>"
flag = flag +1
elseif returncity = "4" and return4 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return date for this request</span><br>"
flag = flag +1
elseif returncity = "5" and return5 = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a return date for this request</span><br>"
flag = flag +1
else
end if
if business = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a business class choice for this request</span><br>"
flag = flag +1
end if
if pickuplocation = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a pickup location for this request</span><br>"
flag = flag +1
end if
if dropofflocation = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a dropofflocation choice for this request</span><br>"
flag = flag +1
end if
if carupgrade = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply a car upgrade choice for this request</span><br>"
flag = flag +1
end if
if cartype = "" and carupgrade = "yes" then
errmsg = errmsg & "<span class=bodyfont> - Since you have opted for a car upgrade you must select car type for this request</span><br>"
flag = flag +1
end if
if cartype = "" and carupgrade = "no" then
end if
if insurance = "" then
errmsg = errmsg & "<span class=bodyfont> - You must supply an insurance choice for this request</span><br>"
flag = flag +1
end if
Function isValidEmail(myEmail)
dim isValidE
dim regEx
isValidE = True
set regEx = New RegExp
regEx.IgnoreCase = False
regEx.Pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
isValidE = regEx.Test(myEmail)
isValidEmail = isValidE
End Function
%>
</td></tr></table>
<%
if flag = 0 then
%>
<%
' read and append to file
Dim userip, counter, filename, path, fs, file
userip = Request.ServerVariables("REMOTE_ADDR")
counter = 1 'compensate for 0
Const ForReading = 1
Const ForAppending = 8
'Map the file name to the physical path on the server.
filename = "requesttgrome.txt"
path = Server.MapPath(".") & "\" & filename
' response.write( path)
'Open and read a text file.
set fs = CreateObject("Scripting.FileSystemObject")
' set file = fs.OpenTextFile(path, ForReading)
' While not file.AtEndOfStream
' file.Readline
' counter = counter + 1
' Wend
' file.Close()
'Append to an existing text file.
' set file = fs.OpenTextFile(path, ForAppending)
' 'AgencyName IATA Address CityStateZip ContactName Phone Fax Email Passenger1First Passenger1Last Passenger1DOB Passenger2First Passenger2Last Passenger2DOB Passenger3First Passenger3Last Passenger3DOB Passenger4First Passenger4Last Passenger4DOB UserIP Date/Time
' file.WriteLine(agencyname &chr(9)& iata &chr(9)& address &chr(9)& citystatezip &chr(9)& contactname &chr(9)& phone &chr(9)& fax &chr(9)& email &chr(9)& passenger1first &chr(9)& passenger1last &chr(9)& passenger1dob &chr(9)& passenger2first &chr(9)& passenger2last &chr(9)& passenger2dob &chr(9)& passenger3first &chr(9)& passenger3last &chr(9) & passenger3dob &chr(9)& passenger4first &chr(9)& passenger4last &chr(9) & passenger4dob &chr(9)& userip &chr(9)& Now())
' file.Close()
%>
<%
sendemail = true
if sendemail = TRUE then
Dim iMsg
Dim iConf
Dim Flds
Dim HTML
'Create the mail object
Set iMsg = Server.CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "127.0.0.1"
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPAuthenticate) = 2
Flds.Update
Dim txtSubject
txtSubject = ""
txtSubject = txtSubject & "Agency Name: " &agencyname & vbCRLF
txtSubject = txtSubject & "IATA: " &iata & vbCRLF
txtSubject = txtSubject & "Address: " &address & vbCRLF
txtSubject = txtSubject & "City, State, Zip: " &citystatezip & vbCRLF
txtSubject = txtSubject & "Contact Name: " &contactname & vbCRLF
txtSubject = txtSubject & "Phone Number: " &phone & vbCRLF
txtSubject = txtSubject & "Fax Number: " &fax & vbCRLF
txtSubject = txtSubject & "Email: " &email & vbCRLF & vbCRLF
txtSubject = txtSubject & "Passenger 1 First Name: " &passenger1first & vbCRLF
txtSubject = txtSubject & "Passenger 1 Last Name: " &passenger1last & vbCRLF
txtSubject = txtSubject & "Passenger 2 First Name: " &passenger2first & vbCRLF
txtSubject = txtSubject & "Passenger 2 Last Name: " &passenger2last & vbCRLF
txtSubject = txtSubject & "Passenger 3 First Name: " &passenger3first & vbCRLF
txtSubject = txtSubject & "Passenger 3 Last Name: " &passenger3last & vbCRLF
txtSubject = txtSubject & "Passenger 4 First Name: " &passenger4first & vbCRLF
txtSubject = txtSubject & "Passenger 4 Last Name: " &passenger4last & vbCRLF & vbCRLF
txtSubject = txtSubject & "ArrivalCity: " &arrivalcity & vbCRLF & vbCRLF
txtSubject = txtSubject & "Departure Date: "&arrival_select1 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Departure Date: "&arrival_select2 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Departure Date: "&arrival_select3 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Departure Date: "&arrival_select4 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Departure Date: "&arrival_select5 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return City: " &returncity & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return Date: " &return7 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return Date: " &return8 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return Date: " &return9 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return Date: " &return10 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Return Date: " &return11 & vbCRLF & vbCRLF
txtSubject = txtSubject & "Business: " &business & vbCRLF & vbCRLF
txtSubject = txtSubject & "Pickup Location: "&pickuplocation & vbCRLF & vbCRLF
txtSubject = txtSubject & "Dropoff Location: "&dropofflocation & vbCRLF & vbCRLF
txtSubject = txtSubject & "Upgrade Car: "&carupgrade & vbCRLF & vbCRLF
txtSubject = txtSubject & "Car Type: "&cartype & vbCRLF & vbCRLF
txtSubject = txtSubject & "Extension: "&extension & vbCRLF & vbCRLF
txtSubject = txtSubject & "Extras: " &extras &vbCRLF & vbCRLF
txtSubject = txtSubject & "Insurance: "&insurance & vbCRLF & vbCRLF
txtSubject = txtSubject & "Date: " &now() &vbCRLF
'HTML = "<html><body>
' Agency Name: &agencyname<br>
' IATA: &iata<br>
' Address: &address<br>
' City, State, Zip: &citystatezip<br>
' Contact Name: &contactname<br>
' Phone Number: &phone
' Fax Number: &fax<br>
' Email: &email<br><br>
'
' Passenger 1 First Name: &passenger1first<br>
' Passenger 1 Last Name: &passenger1last<br>
' Passenger 2 First Name: &passenger2first<br>
' Passenger 2 Last Name: &passenger2last<br>
' Passenger 3 First Name: &passenger3first<br>
' Passenger 3 Last Name: &passenger3last<br>
' Passenger 4 First Name: &passenger4first<br>
' Passenger 4 Last Name: &passenger4last<br><br>
'
' Destination: &destination<br>
' Departure Date: &departuredate<br>
' Return: &return<br>
' Return Date: &returndate<br>
' Insurance: &insurance<br><br>
'
' Date: &now()<br>
' </body></html>"
With imsg
set .Configuration = iConf
.AutoGenerateTextBody = true
' .Fields("urn:schemas:httpmail:importance").Value = 1
' .Fields.Update()
.To = "car@ef-usa.com"
' .bcc = "car@ef-usa.com"
.From = "car@ef-usa.com"
.Subject = "Booking Request EFV (Car Rental)"
' .HTMLBody = txtSubject
.TExtBody = txtSubject
' .AddAttachment "C:\files\a.doc"
.Send
End With
'Create the mail object
Set iMsg = Server.CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "127.0.0.1"
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPAuthenticate) = 2
Flds.Update
txtSubject = ""
txtSubject = ""& contactname &", thank you for your interest in booking the Car Rental offered by Eurofly. Your reservation request has been submitted. One of our representatives will contact you shortly. Thank you for choosing Eurofly, the best way to fly to Italy!"
With imsg
set .Configuration = iConf
.AutoGenerateTextBody = true
' .Fields("urn:schemas:httpmail:importance").Value = 1
' .Fields.Update()
.To = email
' .bcc = "car@ef-usa.com"
.From = "EF-USA Car Rentals<car@ef-usa.com>"
.Subject = "Booking Request (Car Rental)"
' .HTMLBody = txtSubject
.TExtBody = txtSubject
' .AddAttachment "C:\files\a.doc"
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
end if
%>
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="100"></td>
</tr>
<tr>
<td>
<p><font face="Arial">Thank you for your interest in booking the Car Rental offered by Eurofly.</p>
<p>Your reservation request has been submitted. One of our representatives will contact you shortly.</p>
<p>Thank you for choosing Eurofly, the best way to fly to Italy!</p></font></td>
</tr>
</table>
<%
else
Response.Write("<p class=otherfont>You are missing the following below:</p>")
Response.Write("<p class=otherfont>" & errmsg & "</p>")
Response.Write("<p class=otherfont>Please go <a href='javascript:history.go(-1);'>back</a> and include them.</p>")
end if
%>
</body>
</html>
Comment