|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All.
I have created an html form. I started with basic text input boxes and submitted the response to e:mail. All worked fine. Then I decided I wanted to auto populate the department field from an sql database. I have the department box auto-populating successfully, but I am no longer receiving any e:mail after submitting. I am posting the code below. I guess that I should mention that the e:mail address and formatting instructions are included in the simplemail.asp file that I am posting to, so you won't see them here. The simple question is, now that I have the box populated, how do I get what is selected by the user to submit? Any help is appreciated. Thanks - Valerie <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <% 'Create a connection to our database set cnn=server.CreateObject ("adodb.connection") cnn.Open "driver={SQL Server};server=172.10.1.81;uid=Heat;pwd=password;d atabase=heat2" %> <html> <head> <title>Submit A Work Order</title> </head> <body> <form name="heat" method="post" action="http://round/heat/simplemail.asp"> <h2 align="center">Request an Information Services Work Order</h2> Full Name: (required) <input type="text" name="txtEmpName" /><br /> Department: (required) <select name="txtDept"> <% Set oRs=Server.CreateObject("adodb.recordset") strSQL = "SELECT DISTINCT Department FROM Departments" strSQL = strSQL & " ORDER BY Department" oRs.Open strSQL, cnn Do while not oRs.EOF if Request.Form("txtdept") = oRs("Department") then Response.Write "<OPTION VALUE = '" & oRS ("Department") & "' SELECTED>" Response.Write oRs("Department") & "</Option>" oRs.MoveNext else Response.Write "<OPTION VALUE = '" & oRs ("Department") & "'>" Response.Write oRs("Department") & "</Option>" oRs.MoveNext end if loop %> </select> <br /> Phone #, including area code: (required)<br /> Extension: (Optional) <input type="text" name="txtEmpExt" /> <br /> PC Number: (required) <input type="text" name="txtPCNumber" size="12" /><br /> Description or problem or request: (required)<br /> <input type="text" name="txtRemarks" size="80" /><br /> <p> <input type="submit" value="Submit" /> <input type="reset" value="Clear Entry Fields" /> </p> </form> <p>For questions about this form, call the help desk.</p> </body> </html> |
|
#2
|
||||
|
||||
|
The loop you have in your form is using code that will never come into use as the form does not submit to itself, so the two values will never compare. Just use:
Code:
Do while not oRs.EOF
Response.Write "<OPTION VALUE = '" & oRS ("Department") & "' >"
Response.Write oRs("Department") & "</Option>"
oRs.MoveNext
loop
The problem is with your code on the simplemail.asp page. Post the code for that page.
__________________
-
thought-after | my thoughts on web development Get Firefox, the developers browser Budget hosting - recommended [/left] |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Populating drop down box from database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|