Connecting Tech Pros Worldwide Help | Site Map

Cannot post a Drop Down value...

Newbie
 
Join Date: Jun 2009
Posts: 2
#1: Jun 1 '09
Hi, I'm sure there is a simple solution for this but I've been trailing the net for hours trying to find one with no avail. I have an ASP page with a standard html form. On submit the values are loaded into an array and I call an ASP file that emails the values to me. Everything works but it seems to skip the drop down value. Please help....

Expand|Select|Wrap|Line Numbers
  1. <form action="deliver.asp" method="post">
  2.  
  3. <p>First Name: <font color="#FF0000">*</font>
  4. <input name="fname" size="24" type="text" id="fname" value="<%=inputArray(1,2)%>" <%IF badItem=1 THEN response.write "class=""errorItem"""%>/>
  5. </p>
  6.  
  7. <p>Last Name: <font color="#FF0000">*</font>
  8. <input name="lname" size="24" type="text" id="lname" value="<%=inputArray(2,2)%>" <%IF badItem=2 THEN response.write "class=""errorItem"""%>/>
  9. </p>
  10.  
  11. <p>Email: <font color="#FF0000">*</font>
  12. <input name="email" size="30" type="text" id="email" value="<%=inputArray(3,2)%>" <%IF badItem=3 THEN response.write "class=""errorItem"""%>/>
  13. </p>
  14.  
  15. <p>Location: <font color="#FF0000">*</font>
  16. <select name="location" id="location" value="%=inputArray(4,2)%>" <%IF badItem=4 THEN response.write "class=""errorItem"""%>/>
  17. <option value="Queen">King</option>
  18. <option value="King">Rosedale</option>
  19. <option value="Dundas">Forrest Hill</option>
  20. </select>
  21. </p>
  22. <p>Primary Fitness Goal: <font color="#FF0000">*</font><br>
  23. <textarea rows="3" cols="30" name="goal" type="text" id="goal" value="<%=inputArray(5,2)%>" <%IF badItem=5 THEN response.write "class=""errorItem"""%>/></textarea>
  24. </p>
  25.  
  26. <p> 
  27. <input type="submit" value="Submit" />
  28. </p>
  29.  
  30. </form>
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#2: Jun 1 '09

re: Cannot post a Drop Down value...


This is an asp question and you should ask that question on that board.
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 143
#3: Jun 1 '09

re: Cannot post a Drop Down value...


You might want to fix this, for one:

Expand|Select|Wrap|Line Numbers
  1. value="%=inputArray(4,2)%>"
  2.  
Though as far as I know, select elements don't have a value attribute, as they are catered for by option elements.

Can we also see how you are parsing this data?

Gaz
Newbie
 
Join Date: Jun 2009
Posts: 2
#4: Jun 2 '09

re: Cannot post a Drop Down value...


Quote:

Originally Posted by GazMathias View Post

You might want to fix this, for one:

Expand|Select|Wrap|Line Numbers
  1. value="%=inputArray(4,2)%>"
  2.  
Though as far as I know, select elements don't have a value attribute, as they are catered for by option elements.

Can we also see how you are parsing this data?

Gaz


Below is the ASP I'm using.....appreciate the prompt response.I need to know how to populate the array with the option selected.....
<%
'=================================
'All fields are acted as required
' except those the NAME of which
' is in this string variable:
'=================================
exceptions = Array("address")

'=================================
'NAME of the e-mail field is
' stored in this string variable:
'=================================
emailField = "email"

'=================================
'Variables
'=================================
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim fname
Dim lname
Dim email
Dim location
Dim goal
dim errorMessage, badItem, inputArray() : badItem=-1
redim inputArray(50,4)


'=================================
'Get all what is submitted
'=================================
IF request.Form.Count > 0 THEN
execute("const numberOfFields =" & request.Form.Count)
execute("redim inputArray("&numberOfFields&",2)")
FOR i = 1 TO request.Form.Count
inputArray(i,1) = request.Form.Key(i)
inputArray(i,2) = request.Form.Item(i)
NEXT
validate
ELSEIF request.QueryString.Count > 0 THEN
execute("const numberOfFields =" & request.QueryString.Count)
execute("redim inputArray("&numberOfFields&",2)")
FOR i = 1 TO request.QueryString.Count
inputArray(i,1) = request.QueryString.Key(i)
inputArray(i,2) = request.QueryString.Item(i)
NEXT
validate
END IF

SUB validate
'=================================
'Check for empty fields
'=================================
FOR i = 1 TO numberOfFields
isException = False
IF inputArray(i,2)="" THEN
FOR j = 0 to UBound(exceptions)
IF inputArray(i,1) = exceptions(j) THEN isException = TRUE
NEXT
IF NOT isException THEN
badItem = i
errorMessage = "At least one of the required fields is left empty."
EXIT SUB
END IF
END IF
isException = False
NEXT
'=================================
'Check email address for basic
' errors
'=================================
FOR i = 1 TO numberOfFields
IF emailField=inputArray(i,1) THEN
validationResult = validateEmail(inputArray(i,2))
IF validationResult <> "" THEN
errorMessage = validationResult
badItem = i
END IF
END IF
NEXT
END SUB

FUNCTION validateEmail(strAddress)
IF InStr(strAddress,"@") < 2 THEN
validateEmail = "Email address must contain ""@"" sign."
ELSEIF InStr(Right(strAddress,Len(strAddress)-InStr(strAddress,"@")),".") < 2 OR InStr(Right(strAddress,Len(strAddress)-InStr(strAddress,"@")),".") = Len(strAddress)-InStr(strAddress,"@") THEN
validateEmail = "Email address must contain ""."" sign."

END IF
END FUNCTION


%>
<p>&nbsp;</p>
<%
IF errorMessage<>"" THEN
%>
<p class="errorMessage">There was an error with your form: <b><%=errorMessage%></b></p>
<%
ELSEIF request.form.count = 0 AND request.form.count = 0 THEN
%>
<%
ELSE
EmailFrom = "kip1790@hotmail.com"
EmailTo = "kip1790@hotmail.com"
Subject = "Google Membership Request"
fname = Trim(Request.Form("fname"))
lname = Trim(Request.Form("lname"))
email = Trim(Request.Form("email"))
location = Trim(Request.Form("location"))
goal = Trim(Request.Form("goal"))

Dim Body
Body = Body & "First Name: " & fname & VbCrLf
Body = Body & "Last Name: " & lname & VbCrLf
Body = Body & "Email: " & email & VbCrLf
Body = Body & "Location: " & location & VbCrLf
Body = Body & "Primary Fitness Goal: " & goal & VbCrLf

' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send
%>
<font class="body">Thank you, we will be in touch shortly.<p>&nbsp;</p><a href="http://www.totum.ca/">Click here to be directed to our website... </a></font>
<%
response.End
END IF
%>
Reply

Tags
array, asp, drop down, form, post