Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 14th, 2004, 12:47 PM
ewithme8 ewithme8 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 ewithme8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Populating drop down box from database

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>

Reply With Quote
  #2  
Old October 16th, 2004, 09:39 AM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,267 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 48 m 12 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Populating drop down box from database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT