drop down population help needed - thanks

K

Kingdom

In my data base I have a list of componet types e.g. type A - I have 8 off
- type B I have 12 off etc.

I'm using

Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM
Parts_Table")

to populate a drop down but would like to use several drop downs
restricting the contents of each drop down to the records pertaining to one
particular componet type eg a drop down only for type A, only for type B
etc.

can this be done if so how?

The other thing I like to do is add the price field to the drop down list
(two fields in one drop down) is this done just by seperating the fields by
a ","?
 
T

Tom B

You have two choices.
1) Do it server-side. Display just the first drop down box, then when a
selection is made, post the form back to itself, and prepare/present the
second form.
2) Do it client-side. This is the most common approach, and you'll see tons
of examples on the web.

Tom B
 
K

Kingdom

You have two choices.
1) Do it server-side. Display just the first drop down box, then when
a selection is made, post the form back to itself, and prepare/present
the second form.
2) Do it client-side. This is the most common approach, and you'll
see tons of examples on the web.

Tom B
Don't want to do it serverside, don't want to refresh the page untill I
get all the selections.

Telling me that I can find it on the web is a bit like telling me search
engines find things, I know there will be millions of people doing this
but I asked here because here I can communicate with a person rather than
look at some unrelated webpage.

--
We are all in the gutter, but some of us are looking at the stars.

=========================================================================
Walrus Home alt.binaries.pictures.wallpaper <=vote here every weekend.
weekly entries posted on
http://web.newsguy.com/evilsideshowbob/entries.html
FAQ found at http://members.rogers.com/heretic54/
(The most up to date version is posted in alt.binaries.pictures.wallpaper
on Mondays and Thursdays. PLEASE READ BEFORE POSTING)
Walrus websites: http://web.newsguy.com/evilsideshowbob/
For Contest Archives & Artists http://www.weeklywalrus.com
For contestants map http://members.shaw.ca/weeklywalrus/home.html
 
T

Tom B

Then you need to refer to a client side newsgroup.

Or, find a website that does what you like, and look at the source.
 
K

Kingdom

Then you need to refer to a client side newsgroup.

Or, find a website that does what you like, and look at the source.

So what your saying is that if I'm working with ASP and require help with
some aspect that's client based I should'nt seek help here?

And to be halpfull you have gone to the great trouble of pointing out
that other websites have solved this problem and if I look elsewhere I
should find the answer to that which I seek?

Why did you bother to respond at all? you have told me nothing and
explained nothing

--
We are all in the gutter, but some of us are looking at the stars.

=========================================================================
Walrus Home alt.binaries.pictures.wallpaper <=vote here every weekend.
weekly entries posted on
http://web.newsguy.com/evilsideshowbob/entries.html
FAQ found at http://members.rogers.com/heretic54/
(The most up to date version is posted in alt.binaries.pictures.wallpaper
on Mondays and Thursdays. PLEASE READ BEFORE POSTING)
Walrus websites: http://web.newsguy.com/evilsideshowbob/
For Contest Archives & Artists http://www.weeklywalrus.com
For contestants map http://members.shaw.ca/weeklywalrus/home.html
 
B

Bob Barrows

Kingdom said:
So what your saying is that if I'm working with ASP and require help
with some aspect that's client based I should'nt seek help here?

Give the man a cigar!

Client-side questions are off-topic in an asp newsgroup. If you take a look
at the other threads in this newsgroup, you will see that we are happy to
help with asp questions.

There are many reasons to keep the newsgroups focussed on specific topics.
If you're not interested in conforming to basic netiquette then you're not
likely to receive much sympathy.
And to be halpfull you have gone to the great trouble of pointing out
that other websites have solved this problem and if I look elsewhere I
should find the answer to that which I seek?

Why did you bother to respond at all? you have told me nothing and
explained nothing

Would you rather we all just ignore this message leaving you wondering why
nobody has responded? Is that what you consider being helpful?

Tom took time out of his day to try and help you by offering suggestions
about where to find your answer, and you respond by telling him to shut up?
I suppose you're going to tell me to shut up now. Don't bother.

--
HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
D

Dan Brussee

So what your saying is that if I'm working with ASP and require help with
some aspect that's client based I should'nt seek help here?

And to be halpfull you have gone to the great trouble of pointing out
that other websites have solved this problem and if I look elsewhere I
should find the answer to that which I seek?

Why did you bother to respond at all? you have told me nothing and
explained nothing

Actually...

He has explained
1. You are looking for a client side script.
2. You are asking people who are interested in server side script.
3. What you ask can be done.
4. There are people who are better / more ready to help in another
location.

You have explained
1. You are not willing to do any research to find a good answer.
2. You do not understand newsgroups.
3. You are probably not the best person to write the application you
are working on :)
 
K

Kingdom

Yes it may be I need a client based script but my original question was
asp server based.

I'm using

Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM
Parts_Table")

and simply wished to know if this line can include a statement to limit
the records displayed in the drop down to a specific group. Now that
might not be possible, iI don't know but it's not java script and I might
have to look at a million webpages to find one that had the statement I'm
looking for, if it is at all possible.

Hence my post.

I'm sorry if my question was not up to the quality you guys require but
this did seem to be the logical place to ask but rather than someone say
yes do this or no there is no way to do that with this statement I end up
geting a lecture on maners and anything but the statement I seek, put
through the third degree, tried, judged and hanged, and book written
about my impertanence for asking.

Thanks a bunch guys no doubt you were all born with your coding skills!
 
D

Dan Brussee

Yes it may be I need a client based script but my original question was
asp server based.

I'm using

Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM
Parts_Table")

and simply wished to know if this line can include a statement to limit
the records displayed in the drop down to a specific group. Now that
might not be possible, iI don't know but it's not java script and I might
have to look at a million webpages to find one that had the statement I'm
looking for, if it is at all possible.

Hence my post.

I'm sorry if my question was not up to the quality you guys require but
this did seem to be the logical place to ask but rather than someone say
yes do this or no there is no way to do that with this statement I end up
geting a lecture on maners and anything but the statement I seek, put
through the third degree, tried, judged and hanged, and book written
about my impertanence for asking.

Thanks a bunch guys no doubt you were all born with your coding skills!

I think your original request has been munged entirely. The way I
understood it, you wanted to be able to dynamically populate a
dropdown based on a selected value from a list. It was stated that
this could be done server side or client side and you said that you
wanted it done client side so that it would not have to go back to the
server each time the user chose a different group. Good idea, and I
agree with it - but that means that the rest of your application will
need to be done client side... no? Once you know how that will be
done, you MAY need to redo your SQL, but you need to know what you
want client side before anyone can help you get it... no?
 
R

Ray at

This thread is ammusing. Thanks y'all.

Kingdom, thicken your skin. If this is how you react to a post in a
newsgroup, I'd hate to see how you handle real life. Step back and realize
that you received help.

Ray at work
 
K

Kingdom

I think your original request has been munged entirely. The way I
understood it, you wanted to be able to dynamically populate a
dropdown based on a selected value from a list. It was stated that
this could be done server side or client side and you said that you
wanted it done client side so that it would not have to go back to the
server each time the user chose a different group. Good idea, and I
agree with it - but that means that the rest of your application will
need to be done client side... no? Once you know how that will be
done, you MAY need to redo your SQL, but you need to know what you
want client side before anyone can help you get it... no?

Yep, but first I simply need to know if the statement
Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM
Parts_Table")

can incorporate somethig else that will do the job?

If it can what is it?
If it can't be included then I need to do something else!

and someday I'll know enough to know the answer but to day I don't and I'm
asking you people for help.

It seemed a simple question to me, it may be no one hear knows the answer,
well thats fine too but it also seems some would rather riducle and insult
the new guy rather make any effort actualy provide a definative answer that
might actually throw some light on the question.

I honestly didn't come here for a war, I'm not a troll and I'm well used to
getting around news groups.

One guy even starts mouthing off about my life outside off usenet, now what
kinda guy does that when sombody new arrives?

--
We are all in the gutter, but some of us are looking at the stars.

=========================================================================
Walrus Home alt.binaries.pictures.wallpaper <=vote here every weekend.
weekly entries posted on
http://web.newsguy.com/evilsideshowbob/entries.html
FAQ found at http://members.rogers.com/heretic54/
(The most up to date version is posted in alt.binaries.pictures.wallpaper
on Mondays and Thursdays. PLEASE READ BEFORE POSTING)
Walrus websites: http://web.newsguy.com/evilsideshowbob/
For Contest Archives & Artists http://www.weeklywalrus.com
For contestants map http://members.shaw.ca/weeklywalrus/home.html
 
B

Bob Barrows

Now wait a minute. You're leaving something out. From your original post:
to populate a drop down but would like to use several drop downs
restricting the contents of each drop down to the records pertaining
to one particular componet type eg a drop down only for type A, only
for type B etc.

Everyone (well, at least I did) interpreted this to mean that you wished the
options in dropdown B to be dynamically based on the selection in dropdown
A. In other words, the first dropdown would contain the types (A,B, ... ).
When the user selects one, the second dropdown would only display the
components of the type selected in the first dropdown

What you really wish is to have a separate dropdown for each type? That is
much different, and can be accomplished totally within asp.

OK, let's regroup here. You can use the recordset's Filter property to,
well, filter its records. The problem is, I don't know the name of the field
that contains the data to be limited. Your query contains a single field,
Component_type. Is that the field containing the "type A ... type B"? What
is the name of the field whose data you wish to display in these dropdowns?

Could you provide a little more information? Your table structure and some
sample data? It does not have to be real data if it's confidential. Just
enough to illustrate the situation.--

HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
K

Kingdom

Thanks Bob, hope my explanation helps to clarify the situation, I
probably I did not make it clear enough in the original post.

I have the thing running at the moment on the B dropdown depending on the
A dropdown but its not what I want as you cannot easily make changes
without going all the way back through the thing if I can use lots of
drop downs the user could play with it till thay are satisfied with all
the selections before submitting the form, rfreshing the result to get a
proper listing with price totals etc.

Table is called Parts_Table

The product field is called 'Component_Type' with the only other field of
interest being the Price field again called 'Price'


The dbase holds several hundred records but only 34 different types of
product lets call them A,B,C,D, etc so we may have 26xA and 18xb and 6xc
etc.

Now it would suit my purpose to have 34 drop downs each populated from
the Parts_Table, Component_Type field and including the price field for
the selected products. One drop down for each of the 34 different product
type each containing information from two fields

There is no dependancy between the drop downs other than the fat they are
all populated from the same two fields but all contain different records
with no duplicates at all.

The idea being that the the user can select one product from each off the
product type groups in each of the drop downs, see the price and only
when he has done all of this to his satisfaction do I then collect
everything and refresh the page, laying it all out for him with a total
cost and options to mail etc.

eg

drop down 1 Product A - POPULATED BY

A1 PRICE
A2 PRICE
A3 PRICE
A4 PRICE


drop down 2 Product B - POPULATED BY

B1 PRICE
B2 PRICE
B3 PRICE
B4 PRICE
 
T

Tom B

To be clear. You have a table called Parts_Table with the fields -
Component_Type, Price and a field for the name of the part, correct?

What I'd suggest you do, is to query the ENTIRE table, sorted by the
Component_Type then the Component_Name.

Set objRS = objDC.Execute("SELECT UniqueID, Component_Type, Price,
Component_Name FROM Parts_Table ORDER BY Component_Type, Component_Name")

This will give you a recordset with all of the items in your table sorted by
component type. I'd iterate through the list and when you hit a new
Component_Type, start a new select box.

Dim sCurrentComponentType
Set objRS = 'As above
if not objRS.EOF then
sCurrentComponentType=objRS.Fields("Component_Type").Value
Response.Write "<select name=""" & sCurrentComponentType &
""">"
Do While not objRS.EOF
if objRS.Fields("Component_Type").Value <> sCurrentComponentType
then
sCurrentComponentType=objRS.Fields("Component_Type").Value
Response.Write "</select>"
Response.Write "<select name=""" & sCurrentComponentType &
""">"
end if
'Now the individual options

Response.Write "<option value=""" &
objRS.Fields("UniqueID").Value & """>"
objRS.MoveNext
Loop
Response.Write "</select>"
end if
Set objRS=nothing

You should note that Bob will tell you to use GetRows to turn your Recordset
into an array. He's right, I'm sure, but I never do that.

I was away from my computer from my computer for a few hours. I did not
mean to belittle you, I think it was clearly a misunderstanding. The "I
want my second select box to change based on the choice of the first box"
question comes up frequently in this newsgroup, and it's usually the
client-side solution the person is looking for.

Tom
 
K

Kingdom

To be clear. You have a table called Parts_Table with the fields -
Component_Type, Price and a field for the name of the part, correct?

What I'd suggest you do, is to query the ENTIRE table, sorted by the
Component_Type then the Component_Name.

Set objRS = objDC.Execute("SELECT UniqueID, Component_Type, Price,
Component_Name FROM Parts_Table ORDER BY Component_Type,
Component_Name")

This will give you a recordset with all of the items in your table
sorted by component type. I'd iterate through the list and when you
hit a new Component_Type, start a new select box.

Dim sCurrentComponentType
Set objRS = 'As above
if not objRS.EOF then
sCurrentComponentType=objRS.Fields("Component_Type").Valu
e
Response.Write "<select name=""" &
sCurrentComponentType &
""">"
Do While not objRS.EOF
if objRS.Fields("Component_Type").Value <>
sCurrentComponentType
then
sCurrentComponentType=objRS.Fields("Component_Type").Va
lue Response.Write "</select>"
Response.Write "<select name=""" &
sCurrentComponentType &
""">"
end if
'Now the individual options

Response.Write "<option value=""" &
objRS.Fields("UniqueID").Value & """>"
objRS.MoveNext
Loop
Response.Write "</select>"
end if
Set objRS=nothing

You should note that Bob will tell you to use GetRows to turn your
Recordset into an array. He's right, I'm sure, but I never do that.

I was away from my computer from my computer for a few hours. I did
not mean to belittle you, I think it was clearly a misunderstanding.
The "I want my second select box to change based on the choice of the
first box" question comes up frequently in this newsgroup, and it's
usually the client-side solution the person is looking for.

Tom

Thanks Tom, I'v saved the post and I appreciate everyones effors here.
I'll start looking at your suggestions tomorrow I'm still in the early
stages of learning ASP and my head is burned out for now.

I'll try a be a bit clearer if I have any other questions as I'm sure I
will have before I get to the point where I feel I have a handle on it
all.
 
B

Bob Barrows

Tom said:
You should note that Bob will tell you to use GetRows to turn your
Recordset into an array. He's right, I'm sure, but I never do that.

:)
Actually, in this case, I was thinking more in terms of multiple
disconnected recordsets <gasp!>, allowing the Filter property to be used to
make this processing a little easier (I'm going to assume that this is SQL
Server - I will illustrate using dynamic sql, but I suggest you encapsulate
the SQL statements into a stored procedure):

dim rs, rsTypes,rsComps, strSQL
Dim sCurCompType
'open the connection, then

Set rs= server.createobject("adodb.recordset")
rs.cursorlocation=adUseClient
strSQL= "SELECT DISTINCT Component_Type " & _
"FROM Parts_Table ORDER BY Component_Type; " & _
"SELECT UniqueID, Component_Type, Price, Component_Name " & _
"FROM Parts_Table ORDER BY Component_Type, Component_Name"
rs.Open strSQL,cn,,,adCmdText

'put the unique types into a recordset:
set rsTypes = rs.Clone
'disconnect the recordset
set rsTypes.ActiveConnection = nothing
'Put the components into another recordset and disconnect it
set rsComps = rs.NextRecordset
set rsComps.ActiveConnection = nothing

'clean up the initial recordset
rs.Close: set rs=nothing
cn.Close: set cn=nothing

'Create the dropdowns:
do until rsTypes.EOF
sCurCompType = rsTypes(0).Value
Response.Write "Component Type " & sCurCompType & ": "
Response.Write "<select name=""" & sCurCompType & """>"
rsComps.Filter="Component_Type='" & sCurCompType & "'"
do until rsComps.EOF
Response.Write "<option value-""" & rsComps(0).Value
Response.Write """>" & rsComps(2).Value
Response.Write "</option>"
rsComps.MoveNext
loop
Response.Write "</select><BR>"
rsTypes.MoveNext
loop
rsTypes.close:set rsTypes=nothing
rsComps.close:set rsComps=nothing

--
HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
K

Kingdom

:)
Actually, in this case, I was thinking more in terms of multiple
disconnected recordsets <gasp!>, allowing the Filter property to be
used to make this processing a little easier (I'm going to assume that
this is SQL Server - I will illustrate using dynamic sql, but I
suggest you encapsulate the SQL statements into a stored procedure):

dim rs, rsTypes,rsComps, strSQL
Dim sCurCompType
'open the connection, then

Set rs= server.createobject("adodb.recordset")
rs.cursorlocation=adUseClient
strSQL= "SELECT DISTINCT Component_Type " & _
"FROM Parts_Table ORDER BY Component_Type; " & _
"SELECT UniqueID, Component_Type, Price, Component_Name " & _
"FROM Parts_Table ORDER BY Component_Type, Component_Name"
rs.Open strSQL,cn,,,adCmdText

'put the unique types into a recordset:
set rsTypes = rs.Clone
'disconnect the recordset
set rsTypes.ActiveConnection = nothing
'Put the components into another recordset and disconnect it
set rsComps = rs.NextRecordset
set rsComps.ActiveConnection = nothing

'clean up the initial recordset
rs.Close: set rs=nothing
cn.Close: set cn=nothing

'Create the dropdowns:
do until rsTypes.EOF
sCurCompType = rsTypes(0).Value
Response.Write "Component Type " & sCurCompType & ": "
Response.Write "<select name=""" & sCurCompType & """>"
rsComps.Filter="Component_Type='" & sCurCompType & "'"
do until rsComps.EOF
Response.Write "<option value-""" & rsComps(0).Value
Response.Write """>" & rsComps(2).Value
Response.Write "</option>"
rsComps.MoveNext
loop
Response.Write "</select><BR>"
rsTypes.MoveNext
loop
rsTypes.close:set rsTypes=nothing
rsComps.close:set rsComps=nothing

Thanks Bob

I'm actually using an ACCESS data base on ISS5, compleate newby, will
there be much alteration reqired?

--
We are all in the gutter, but some of us are looking at the stars.

=========================================================================
Walrus Home alt.binaries.pictures.wallpaper <=vote here every weekend.
FAQ found at http://members.rogers.com/heretic54/
(The most up to date version is posted in alt.binaries.pictures.wallpaper
on Mondays and Thursdays. PLEASE READ BEFORE POSTING)
For Contest Archives, Artists & weekly entries
http://www.weeklywalrus.com
 
B

Bob Barrows

Kingdom said:
Thanks Bob

I'm actually using an ACCESS data base on ISS5, compleate newby, will
there be much alteration reqired?

A slight alteration. Access cannot handle batched queries, so you would have
to open two separate recordsets, one from each query. It would look like
this:

dim rsTypes,rsComps, strSQL
Dim sCurCompType
'open the connection, then

Set rsTypes= server.createobject("adodb.recordset")
rsTypes.cursorlocation=adUseClient
strSQL= "SELECT DISTINCT Component_Type " & _
"FROM Parts_Table ORDER BY Component_Type; "
rsTypes.Open strSQL,cn,,,adCmdText
'disconnect the recordset
set rsTypes.ActiveConnection = nothing

Set rsComps= server.createobject("adodb.recordset")
rsComps.cursorlocation=adUseClient
strSQL= "SELECT UniqueID, Component_Type, Price, Component_Name " & _
"FROM Parts_Table ORDER BY Component_Type, Component_Name"
rsComps.Open strSQL,cn,,,adCmdText
'disconnect the recordset
set rsComps.ActiveConnection = nothing
cn.Close: set cn=nothing

'The rest is unchanged


--
HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
B

Bob Barrows

Kingdom said:
I'm actually using an ACCESS data base on ISS5, compleate newby, will
there be much alteration reqired?

I just wanted to add that you would not want to do it this way if your table
contained thousands of rows of data. You would be better off using two
dropdowns: one for the user to select a type, the other to display the
corresponding items based on the type selected.

With a few hundred records, however, both methods should work well. Frankly,
with an Access database, I would be leaning more towards Tom's method.

--
HTH,
Bob Barrows - ASP MVP
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
K

Kingdom

I just wanted to add that you would not want to do it this way if your
table contained thousands of rows of data. You would be better off
using two dropdowns: one for the user to select a type, the other to
display the corresponding items based on the type selected.

With a few hundred records, however, both methods should work well.
Frankly, with an Access database, I would be leaning more towards
Tom's method.

Thanks Bob I'll work with this and Toms tommorow and see how it shapes
up.

Wish I could learn faster!

Thanks for taking the time with this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top