PDA

View Full Version : Populating a Combo Box


Abd
06-04-2003, 09:23 AM
Hi All,

I have a situation where I am populating a Combo Box with the bellow code, but I now want to have two Combo Boxes. Scenerio is, if I load the form I want only the first Combo Box to be populated, then when I select a value from the first Combo Box, the second Combo Box should be populated, that is the selected value of the first Combo Box should be used for the "where" clause of the second Combo Box. The data that is used for populating both Combo Boxes are in the same table and Database. Bellow is my code;


<%
'Populating Source ComboBox

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.open "DSN=dsn;UID=uid;PWD=pwd;DATABASE=DB"

Set rs=oConn.execute("Select source from services where source <> 'NULL'")


response.write "<b>Source:</b>&nbsp;<select name='source'>"&vbcrlf
while not rs.eof
response.write "<option value="""&rs("source")&""">"&rs("source")&"</option>"&vbcrlf
rs.movenext
wend
response.write "</select>"&vbcrlf

rs.close
set rs=nothing
oConn.close
set oConn=nothing
%>


thanks

Abd

raf
06-04-2003, 09:45 AM
Fastest way to get an aswer = run a search. There should be quite some threads about it. Like this one
http://www.codingforums.com/showthread.php?s=&threadid=15258&highlight=populate
with complete code and all. (you need to do some scrolling to page 2, post of 03-03-2003 10:25 PM)

You basically have two options
- use clientside javascript (if it's a small table)
- do it serversided in a multi-purpose page (page is posted to itself) of in a framepage.

Abd
06-04-2003, 10:39 AM
thank raf,

Abd

;)