Results 1 to 2 of 2

Thread: Combo Boxes HELP!!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Location
    N.Ireland
    Posts
    651

    Wink

    Im trying to populate a single combo box using Javascript. I dont know how to fill the combo box with the data which is stored in my database??(Dynamically)Rather than simply hard coding the data in my ASP page, i want the data to be dynamically built from my VB.

    Any ideas?
    Gilly

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    try this:

    Code:
    <%@ Language=VBScript %>
    <%option explicit%>
    <HTML>
    
    <!--
    Written by Mark Sreeves
    -->
    
    <%
    
    	
    	dim conn	'the database conection
    	dim rst		'recordset
    	dim strSQL	'SQL string
    	dim i		' my usual loop counter
    	
    	'create the connection  object
    	Set Conn = Server.CreateObject("ADODB.Connection")
    	
    	'open the database
    	Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\myDB.mdb")
    
    %>
    <BODY>
    <form name="frm1">
    
    <SELECT name=select1>
    
    <%
    
    ' populate list 1 from the database
    strSQL = "SELECT * FROM table1;"
    Set rst = Conn.Execute(strSQL)
    
    do while not rst.EOF
    		'fill the combo box
    %>
    	<OPTION value="<%=rst("id")%>"><%=rst("list1")%>
    <%
    	rst.MoveNext
    	
    	loop
    	'close the record set a
    	rst.close
    	'and database connection
    	conn.Close
    	
    	'free resources...
    	set conn = nothing
    	set rst = nothing
    %>
    
    </SELECT>     
    
          
    </form>   
    </BODY>
    </HTML>
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width