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

ASP/Access multi-Combo box

Status
Not open for further replies.

Nordyck

Programmer
Aug 16, 2001
57
US
The problem I'm having is when the user selects the first combo box, it suppost to populate the second box. What I need to do is to retrive the selected value from the combobox and pass it into a select statement for the second.

Combo1 (SelectPrimary) has 3 fixed values and the remaining is retrieved from a table. - This works correctly.

Problem code -----------------
if (menuNum >= 3)
{
siteopt = new Array;
<%
m = &quot;Govt&quot;
m = request(&quot;SelectPrimary&quot;)
strsql = &quot;SELECT * FROM webGrpSub Where WebGrp='&quot; & m & &quot;'&quot;
set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open strsql, conn, 1, 2
i = 0
rs.movefirst
do while not rs.eof %>
siteopt[<%=i%>] = new Option(&quot;<%=rs(&quot;WebGrpSub&quot;)%>&quot;);
<%i = i + 1
rs.movenext
loop
%>
}

When I default the sql to a value, it works fine, but if I use the request it doesn't. Also I'm not using a form.
MenuNum is an index number of the selected item from combo1.

I'm modifing the code that I got from:
nordycki@hotmail.com
 
I think you will need another trip to the server to populate the second combo box.

Falcon
 
Falcon99, No offence but your comment made no sense.
If I comment out the line m = request(&quot;SelectPrimary&quot;), and set m = 'Govt' or any values that's in the table, it returns the all the fields that equals to 'Govt'. The problem again is I'm not able to extract the value from the combo box and set m equal to. nordycki@hotmail.com
 
Do a
Response.Write &quot;Passed value:&quot; & Request(&quot;SelectPrimary&quot;) & &quot;:End passed value&quot;
Response.End

near the top of your code.
It appears that the value is either not being passed correctly, or it's something else minor.
I would bet it's either not being passed(differant name on form input/select), miscapitalized, extra spaces, or you have more than one form element on the previous page with that name and it is creating a comma delimited string with the two values.

Also you should probably switch this to Request.Form or Request.QueryString depending if your form is POST or GET respectively. Using Request without a qualifying collectiong means it has to search each collection until it finds a value, which is a minor hit on your processing time.
I think the order is Post, QueryString, Cookie, Session or something like that anyways.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
FAQ FAQ20-2863
= new Forums.Posting.General.GettingAnswers()
 
Sorry fo the confusion. It wasn't clear to me if the first combo was coming from a different page or reposting to itself.

 
Thanks Falcon99 and Tarwn but I did manage to solve it couple of days ago.

I had the wrong approached, my thought was when you changed the value in combo1, it will go to the database and fill combo2. When I modified the code to build all of the arrays that will be used for combo2, via nested loop, it worked.

Nordyck nordycki@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top