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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo boxs

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Please help, I am getting the first combo box to work great, but I have to pass the selection from the first box to a second box, and the select from the second to a final 3rd box. I am having a hard time following the code, I am pretty new to asp, and my books are horrible.

here is the code I have that works:
-------------------------------------------------------
<%@ Language=VBScript %>
<%Option explicit
Dim oRs, conn, connect, strSQL

set conn=server.CreateObject (&quot;adodb.connection&quot;)
connect = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.MapPath(&quot;agents.mdb&quot;) & &quot;;Persist Security Info=False&quot;
conn.Open connect
%>
<html>
<head>
<title>combo box</title>
<script language=&quot;javascript&quot;>
<!--
function dept_onchange(frmSelect) {
frmSelect.submit();
}

//-->
</script>
</head>
<body>
The following was selected : <%=Request.Form (&quot;agents&quot;)%>

<form name=&quot;frmSelect&quot; method=&quot;Post&quot; action=&quot;select.asp&quot;>
<SELECT name=agents LANGUAGE=javascript onchange=&quot;return dept_onchange(frmSelect)&quot;>
<%
Set oRs=Server.CreateObject(&quot;adodb.recordset&quot;)
strSQL = &quot;SELECT DISTINCT Country FROM agents ORDER BY Country&quot;
oRs.Open strSQL, conn

Do while not oRs.EOF
if Request.Form(&quot;agents&quot;) = oRs(&quot;Country&quot;) then 'if this is the selected one then display as selected
Response.Write &quot;<OPTION VALUE = '&quot; & oRS (&quot;Country&quot;) & &quot;' SELECTED>&quot;
Response.Write oRs(&quot;Country&quot;) & &quot;</Option>&quot;
oRs.MoveNext
else
Response.Write &quot;<OPTION VALUE = '&quot; & oRs (&quot;Country&quot;) & &quot;'>&quot;
Response.Write oRs(&quot;Country&quot;) & &quot;</Option>&quot;
oRs.MoveNext
end if
loop
%>
</SELECT>
</form>

</body>
</html>

----------------------------------------------------------

This displays correctly what was selected when it runs. I really need it to go back to my access table and select agents.pagent & agents.sagent WHERE (selected country) = agents.country and populate that combo box with just the Primary & secondary agent (if there is 2) for that country.


any help is always really appreciated.

thank in advance,
-Mike
 
I am a little closer, I added this at the bottom:

<% Sel1 = Request.Form (&quot;agents&quot;) %>
<SELECT name=agents LANGUAGE=javascript onchange=&quot;return dept_onchange(frmSelect)&quot;>
<%
Set oRs=Server.CreateObject(&quot;adodb.recordset&quot;)
strSQL = &quot;SELECT DISTINCT * FROM agents WHERE agents.country LIKE Sel1&quot;
oRs.Open strSQL, conn
Do while not oRs.EOF

if Request.Form(&quot;agents&quot;) = oRs(&quot;Country&quot;) then
Response.Write &quot;<OPTION VALUE = '&quot; & oRS (&quot;pagent&quot;) & &quot;' SELECTED>&quot;

Response.Write oRs(&quot;PAgent&quot;) & &quot;</Option>&quot;
oRs.MoveNext
else
Response.Write &quot;<OPTION VALUE = '&quot; & oRs (&quot;pagent&quot;) & &quot;'>&quot;
Response.Write oRs(&quot;pagent&quot;) & &quot;</Option>&quot;
oRs.MoveNext
end if
loop
%>
</SELECT>

This does not populat anything in the lower box, but if UI change the select to:

SELECT DISTINCT * FROM agents

It Displays all the agents from the table. I am trying to only display the agents that match the country that is selected in the first box. I am trying to use a variable Sel1 to do it.


please help

thanks in advance.

-Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top