I am trying to populate dropdown options in a form so the user can make the selection and when they hit submit the jobs the contractor is involved with will show in another section of the page. I have 13 records in the database. As of now it is populating the options with one record 13 times. I guess my logic is off. Also, ultimately I would like to do a string comparison on the field I'm querrying so that when the dropdown gets populated there are no duplications.
Here is what I have so far...
<form action="Contractor_Job_Search2.asp" method="get">
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr><td><img src="img/spacer.gif" width="100" height="10"></td></tr>
<tr>
<td align="right">
<%
set connection = server.createobject("ADODB.Connection")
connection.open session("DBConnString")
sql = "select * from Projects"
sql = sql & " order by Contractor DESC"
set rs = connection.execute(sql)
Contractor=rs("Contractor")
%>
<%
response.Write "<select name=Contractor size=1 class=FieldValue>"
response.Write "<option value= selected>" & "Select Contractor" & "</option>"
While Not rs.EOF
response.Write "<option value=" & Contractor & ">" & Contractor & "</option>"
counter = counter +1
rs.MoveNext
Response.Flush()
WEND
response.write "</select>"
%>
</td>
</tr>
<tr><td><img src="img/spacer.gif" width="100" height="10"></td></tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="Submit" class="button">
<input type="reset" name="reset" value="Reset" class="button"></td>
</tr>
</table>
</form>
Here is the code that is supposed to show all the job titles for the selected contractor...
<%
Contractor = request.form("Contractor")
if request.form("Contractor") = "" then
response.Write("Please select a General Contractor and press enter!")
else
response.write "<font color=#000000 size=2>" & Contractor & "</font>" & "<br><br>"
While Not rs.EOF
Title=rs("Title")
response.Write Title & "<br>"
counter = counter +1
rs.MoveNext
Response.Flush()
WEND
if Contractor = "" then
response.Write"<strong>"& ("There are no projects involving") & " " & request.form("Contractor") & " " & ("at this time") & "<strong>"
end if
end if
%>
I would really appreciate any help you could give me
Thanks
Here is what I have so far...
<form action="Contractor_Job_Search2.asp" method="get">
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr><td><img src="img/spacer.gif" width="100" height="10"></td></tr>
<tr>
<td align="right">
<%
set connection = server.createobject("ADODB.Connection")
connection.open session("DBConnString")
sql = "select * from Projects"
sql = sql & " order by Contractor DESC"
set rs = connection.execute(sql)
Contractor=rs("Contractor")
%>
<%
response.Write "<select name=Contractor size=1 class=FieldValue>"
response.Write "<option value= selected>" & "Select Contractor" & "</option>"
While Not rs.EOF
response.Write "<option value=" & Contractor & ">" & Contractor & "</option>"
counter = counter +1
rs.MoveNext
Response.Flush()
WEND
response.write "</select>"
%>
</td>
</tr>
<tr><td><img src="img/spacer.gif" width="100" height="10"></td></tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="Submit" class="button">
<input type="reset" name="reset" value="Reset" class="button"></td>
</tr>
</table>
</form>
Here is the code that is supposed to show all the job titles for the selected contractor...
<%
Contractor = request.form("Contractor")
if request.form("Contractor") = "" then
response.Write("Please select a General Contractor and press enter!")
else
response.write "<font color=#000000 size=2>" & Contractor & "</font>" & "<br><br>"
While Not rs.EOF
Title=rs("Title")
response.Write Title & "<br>"
counter = counter +1
rs.MoveNext
Response.Flush()
WEND
if Contractor = "" then
response.Write"<strong>"& ("There are no projects involving") & " " & request.form("Contractor") & " " & ("at this time") & "<strong>"
end if
end if
%>
I would really appreciate any help you could give me
Thanks