Jump to content

Linking combo boxes


Recommended Posts

I was wondering if anyone knows how to link combo boxes, that are populated from an access database, so if you click on a choice in one combo box it will display the associated data in the second combo box.

Link to post
Share on other sites
I was wondering if anyone knows how to link combo boxes, that are populated from an access database, so if you click on a choice in one combo box it will display the associated data in the second combo box.

Hi bairdb,You should use an onChange event in your first combo box, then catch the variable you selected to build the second combo box. Here is my version, you just need to add your connection.inc and your 2 queries. Hope it will be helpfull,JeromecmbBox.asp
<%@ Language=VBScript%><!-- #INCLUDE FILE = "../connection.inc" --><%Dim cmbItem1, cmbItem2 cmbItem1 = Trim(Request("cmbItem1"))%><html><head><title>Combo box</title></head><body><form name="frm" method="post" action="cmbBox.asp"><!--Here, you should insert your loop and your sql query to populate the first combo box...--><select name="cmbItem1" onChange="submit();"><option value="">- - - -</option><option value="Item1" <%If cmbItem1="Item1" Then Response.Write("SELECTED") End If%>>Item1</option><option value="Item2" <%If cmbItem1="Item2" Then Response.Write("SELECTED") End If%>>Item2</option><option value="Item3" <%If cmbItem1="Item3" Then Response.Write("SELECTED") End If%>>Item3</option></select><%'Use the variable cmbItem to make your second sql query and populate the second combo box...If Len(cmbItem1) Then Response.Write("<select name=""cmbItem2""><option value=""" & cmbItem1 & """>" & cmbItem1 & "</option></select>")End If%></form></body></html>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...