PDA

View Full Version : Pull Name from DropDown Instead of Value


LauraWord
12-10-2009, 10:10 PM
Is there a way to pull the value of a drop down selection in one place in the ASP, and pull the name from the same field in another?


Drop Down Code


<select size="1" name="Brand" tabindex="4">
<option>Choose One</option>
<option value="EmailAddress1" name="BrandInitals1">Brand Name1</option>
<option value="EmailAddress2" name="BrandInitals2">Brand Name2</option>
<option value="EmailAddress3" name="BrandInitals3">Brand Name3</option>
</select>


ASP Code

<%

'Dim Your_Name, Your_Id, Your_Site, Order, Brand, Customer_Name, Customer_Phone, Alternate_Phone, Explaination

body = "<TABLE>"
body = body + "<TR><TD>Name:</TD><TD>" + Request.Form("Your_Name") + "</TD></TR>"
body = body + "<TR><TD>ID:</TD><TD>" + Request.Form("Your_Id") + "</TD></TR>"
body = body + "<TR><TD>Site:</TD><TD>" + Request.Form("Your_Site") + "</TD></TR>"
body = body + "<TR><TD>Order#:</TD><TD>" + Request.Form("Order") + "</TD></TR>"
body = body + "<TR><TD>Customer:</TD><TD>" + Request.Form("Customer_Name") + "</TD></TR>"
body = body + "<TR><TD>Phone:</TD><TD>" + Request.Form("Customer_Phone") + "</TD></TR>"
body = body + "<TR><TD>Alternate:</TD><TD>" + Request.Form("Alternate_Phone") + "</TD></TR>"
body = body + "<TR><TD>Explaination:</TD><TD>" + Request.Form("Explaination") + "</TD></TR>"
body = body + "<TR><TD colspan=""2"">Instructions Here. </TD><TD>" + "</TD></TR>"

set mailbot = Server.CreateObject("CDO.message")

mailbot.To = Request.Form("Brand") //I want EmailAddress here
'mailbot.CC = ""
'mailbot.BCC = ""
mailbot.From = ""
mailbot.Subject = Request.Form("Brand") //I want BrandInitals here
mailbot.HTMLBody= body
mailbot.Send

set mailbot = nothing

response.redirect "Thank_You.htm"

%>

Old Pedant
12-10-2009, 10:37 PM
No such thing as a NAME attribute for an <OPTION>. HTML is simply ignoring all you name= in those <option>s.

Try this:

<select size="1" name="Brand" tabindex="4">
<option>Choose One</option>
<option value="EmailAddress1::BrandInitals1">Brand Name1</option>
<option value="EmailAddress2::BrandInitals2">Brand Name2</option>
<option value="EmailAddress3::BrandInitals3">Brand Name3</option>
</select>

And then, in the ASP code:

...
brandInfo = Split( Trim( Request.Form("Brand") ), "::" )
email = brandInfo(0)
brandinit = brandInfo(1)

mailbot.To = email
...
mailbot.Subject = brandinit
...


You can use any delimiter you want in place of the "::" so long as it will never appear in the actual data you want.

jonweb2009
12-27-2009, 10:21 PM
You can get only value from the dropdownlist in ASP using forms collection.

You can get name and value if you use ASP.NET

so in classical asp use delimiter as said before either : or , to add more values

http://www.******************