Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDown Values From database-2

Status
Not open for further replies.

LinuxGuy

Programmer
Nov 18, 2002
37
0
0
US
<select type=&quot;text&quot; name=&quot;x_Customer&quot; value=&quot;<%= x_Customer %>&quot;>

i need code to go along with my Dropdown feild that Grabs the Vendors Company Name, (&quot;vendorName&quot;) from the Table Vendors and Places it into a dropdown Box

 
I am assuming you already have a connection object named objCon. The following code will populate a drop down menu with the values from the vendors database:

<select name=&quot;customer&quot;>
<%

strSQL = &quot;SELECT * FROM Vendors&quot;

Dim rs
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

rs.Open strSQL, objCon, 3

If Not rs.EOF Then
Do Until rs.EOF %>

<option name=&quot;<%=rs(&quot;vendorName&quot;)%>&quot; value=&quot;<%=rs(&quot;vendorName&quot;)%>

<% rs.MoveNext
Loop
End If

rs.Close

%>
</select>

Hope this works for you.


Nick (Software Developer)


nick@retrographics.fsnet.co.uk
nick.price@myenable.com
 
this is what i have So far
</tr>
<tr>
<td bgcolor=&quot;#3366CC&quot;><strong><font color=&quot;#FFFFFF&quot;><font size=&quot;-1&quot;>Customer</font>&nbsp;</font></strong></td>
<td bgcolor=&quot;#999999&quot;><font size=&quot;2&quot;>
<select type=&quot;text&quot; name=&quot;x_Customer&quot; value=&quot;<%= x_Customer %>&quot;>
<%
sql &quot;select * from Customers&quot;
while not rs.Eof
%>
<option value=&quot;<%=rs(&quot;id&quot;)%>&quot;><%=rs(&quot;Customers&quot;)%>
<%
rs.MoveNext
when
%>
</select>

</font><font color=&quot;#999999&quot; size=&quot;-1&quot;>&nbsp; </font><font size=&quot;2&quot;>
 
It's Cutting Off my Page So Nothing Shows below Customer Drop Down Box its all gone But Code is still there
Heeellppp

</tr>
<tr>
<td bgcolor=&quot;#3366CC&quot;><strong><font color=&quot;#FFFFFF&quot;><font size=&quot;-1&quot;>Customer</font>&nbsp;</font></strong></td>
<td bgcolor=&quot;#999999&quot;><font size=&quot;2&quot;>&nbsp; </font><font color=&quot;#999999&quot; size=&quot;-1&quot;>&nbsp;</font><font color=&quot;#666666&quot;><strong><font size=&quot;2&quot;>

<select type=&quot;text&quot; name=&quot;x_Customer&quot; value=&quot;X_Customer&quot;>
<%
sql &quot;select Company from Contacts&quot;
If Not rs.EOF Then
Do Until rs.EOF %>
<option value=&quot;<%=rs(&quot;Company&quot;)%>&quot;><%=rs(&quot;Company&quot;)%></option>
<% rs.MoveNext
Loop
End If
rs.Close
%>
</select>

</font></strong></font><font color=&quot;#999999&quot; size=&quot;-1&quot;>&nbsp; </font><font size=&quot;2&quot;>
 
This should do the trick (please note i removed some of your unnecessary font tags as well):


<tr>
<td bgcolor=&quot;#3366CC&quot;>
<strong>
<font color=&quot;#FFFFFF&quot; size=&quot;-1&quot;>Customer</font>
</strong>
</td>
<td bgcolor=&quot;#999999&quot;>

<select type=&quot;text&quot; name=&quot;x_Customer&quot; value=&quot;X_Customer&quot;>

<%
Dim sql

sql = &quot;select Company from Contacts&quot;

Dim rs
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

rs.Open sql, objCon, 3
If Not rs.EOF Then
Do Until rs.EOF

%>
<option value=&quot;<%=rs(&quot;Company&quot;)%>&quot;>
<%=rs(&quot;Company&quot;)%>
</option>
<%

rs.MoveNext
Loop
End If
rs.Close
%>

</select>
</td>
</tr>

Nick (Software Developer)


nick@retrographics.fsnet.co.uk
nick.price@myenable.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top