472,961 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Conditional List Box in ASP

Hi there,

I am having a few problems compiling a list box that is conditional on what
is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List
Box (lstRegion) is selected East or West. Basically the areas will change
when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working code is
as follows, my syntax in the SQL statement is completly wrong, i have no
idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the new list
box (lstArea) to display vchrArea_Name when the List Box lstRegion displays
vchrLong_Desc.

************************
<select name="lstArea" size="1"><br>
<option value="">Please Select </option>
<%
Dim SQL, RS,

SQL = "SELECT * from vw_SOLS_RegionsAreas_u WHERE
vw_SOLS_RegionsAreas_u.vchrLong_Desc =" ("lstRegion")""

set RS = DataConnection.Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write("<option
value='"&RS("vchrArea_Name")&"'>"&RS("vchrArea_Nam e")&"</option>")
RS.movenext()
wend
else
Response.write("")
end if
%>
</select>
***************************

Hope that is not too confusing,
I am new to ASP so you will have to forgive me for being nieve

Thanks in advance

Guy
Jul 19 '05 #1
8 1829
Guy Hocking wrote:
Hi there,

I am having a few problems compiling a list box that is conditional
on what is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the
List Box (lstRegion) is selected East or West. Basically the areas
will change when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working
code is as follows, my syntax in the SQL statement is completly
wrong, i have no idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the
new list box (lstArea) to display vchrArea_Name when the List Box
lstRegion displays vchrLong_Desc.


http://www.aspfaq.com/show.asp?id=2270

Bob Barrows

PS. I realize you are new, so you probably are not aware that you've
committed a breach of netiquette here by posting an off-topic question.

Just so you know, ASP is server-side technology, ie, it operates on the web
server. By the time the client sees anything in the browser, ASP is usually
finished. All subsequent operations (such as responding to users' actions:
clicking with the mouse or selecting an option in a listbox) are no longer
ASP operations, making them off-topic for this newsgroup. The appropriate
newsgroups for this type of question (client-side code) are those that
contain "dhtml" (dynamic html) in their names, or
microsoft.public.scripting.jscript, or microsoft.public.scripting.vbscript.
With a few exceptions, questions about activity that occurs on the server
(server-side code) before the client sees the response in the browser, are
the only on-topic questions for these asp newsgroups. (I notice you included
the .iis newsgroup, which was totally inappropriate, since that newsgroup
deals with the web server itself). It helps to browse a little in the
newsgroups before posting to see which types of questions are deemed
appropriate - you may even discover the answer to your question without
posting. Use Google to seach for answers before posting: you will save
yourself (and us) some time.

I do congratulate you for cross-posting instead of multi-posting, however.
Nothing burns us up more than responding to a question in one newsgroup only
to find it's been answered in another group.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
Hi,

I appreciate your points made in your reply, however, the code i am talking
about may well be client side but it will post it to an ASP page to sort out
and display the detail.
Explain this to me, how will i get the data from the SQL server onto the
page in the first place? will it not need to be an ASP page in order to do
this - then sort out the client options once its there?
If this is incorrect forgive me, as i stated i am new to ASP and its
sisters.

Please forgive me, as i feel your response was kind of patronising, i
appreciate what you guys do as i frequently answer questions in the Exchange
newsgroups, but your post was simply a point being made rather than helping
me with my query.
Whether client or server side the operation still contains ASP at some
stage, making this post not so as in-appapropriate as you make out.

I will post to the apropriate newsgroups, my apologies to any other MVP with
their knickers in a twist,

Kind Regards

Guy Hocking
MCSE

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:#w**************@tk2msftngp13.phx.gbl...
Guy Hocking wrote:
Hi there,

I am having a few problems compiling a list box that is conditional
on what is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the
List Box (lstRegion) is selected East or West. Basically the areas
will change when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working
code is as follows, my syntax in the SQL statement is completly
wrong, i have no idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the
new list box (lstArea) to display vchrArea_Name when the List Box
lstRegion displays vchrLong_Desc.

http://www.aspfaq.com/show.asp?id=2270

Bob Barrows

PS. I realize you are new, so you probably are not aware that you've
committed a breach of netiquette here by posting an off-topic question.

Just so you know, ASP is server-side technology, ie, it operates on the

web server. By the time the client sees anything in the browser, ASP is usually finished. All subsequent operations (such as responding to users' actions:
clicking with the mouse or selecting an option in a listbox) are no longer
ASP operations, making them off-topic for this newsgroup. The appropriate
newsgroups for this type of question (client-side code) are those that
contain "dhtml" (dynamic html) in their names, or
microsoft.public.scripting.jscript, or microsoft.public.scripting.vbscript. With a few exceptions, questions about activity that occurs on the server
(server-side code) before the client sees the response in the browser, are
the only on-topic questions for these asp newsgroups. (I notice you included the .iis newsgroup, which was totally inappropriate, since that newsgroup
deals with the web server itself). It helps to browse a little in the
newsgroups before posting to see which types of questions are deemed
appropriate - you may even discover the answer to your question without
posting. Use Google to seach for answers before posting: you will save
yourself (and us) some time.

I do congratulate you for cross-posting instead of multi-posting, however.
Nothing burns us up more than responding to a question in one newsgroup only to find it's been answered in another group.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #3

if you reread Bobs post the very first line was helping you...

Look at all the links and that will tell you how to do it.

Basically you need CLIENT side code to change the drop down boxes with
information... once you get that look at it and learn how its doing
it.. once you got that then you can tell the client side code the date
from the ASP db you need.
If you find that client side javascript code is to advanced for you
then you will have to do it server side, but this is not as
"professional" as it calls back to the server each time.
check out matts site for more info.

http://www.mattkruse.com/javascript/

Al.

On Thu, 8 Jan 2004 12:06:14 -0000, "Guy Hocking"
<gu*********@bradflack.com> wrote:
, but your post was simply a point being made rather than helping
me with my query.


Jul 19 '05 #4

"Guy Hocking" <gu*********@bradflack.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi there,

I am having a few problems compiling a list box that is conditional on what is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List
Box (lstRegion) is selected East or West. Basically the areas will change
when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working code is
as follows, my syntax in the SQL statement is completly wrong, i have no
idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the new list box (lstArea) to display vchrArea_Name when the List Box lstRegion displays vchrLong_Desc.

************************
<select name="lstArea" size="1"><br>
<option value="">Please Select </option>
<%
Dim SQL, RS,

SQL = "SELECT * from vw_SOLS_RegionsAreas_u WHERE
vw_SOLS_RegionsAreas_u.vchrLong_Desc =" ("lstRegion")""
This last bit could be a problem.... for lots of reasons.

Are you having your page submit when the first box is selected? Are all your
select boxes in a Form?

You would need to have something like this :

<%
If Request.Form() <> "" Then ' Form submitted'
DropDown1 = Trim(Request.Form("DropDown1"))

If DropDown1 <> "" Then
sSQL = "SELECT * FROM vw_SOLS_RegionsAreas_u WHERE sw_etc = '" &
DropDown1 & "'"
Set RS = DataConn.Execute(SQL)
If NOt (RS.eof and RS.BOF) Then
Response.write "<Select name = ""DropDown2"">"
Do While Not Rs.Eof
Response.write "<option value = """ & RS("WhichEverIDField") &
""">" & RS("WhichEverTextField
Rs.Movenext
Loop
Response.write "</select>"
Else
Response.write "No records found!"
End If
RS.CLose
Set RS = Nothing
End If
%>

set RS = DataConnection.Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write("<option
value='"&RS("vchrArea_Name")&"'>"&RS("vchrArea_Nam e")&"</option>")
RS.movenext()
wend
else
Response.write("")
end if
%>
</select>
***************************

Hope that is not too confusing,
I am new to ASP so you will have to forgive me for being nieve

Thanks in advance

Guy

Jul 19 '05 #5
On Thu, 8 Jan 2004 12:06:14 -0000, "Guy Hocking"
<gu*********@bradflack.com> wrote:
I appreciate your points made in your reply, however, the code i am talking
about may well be client side but it will post it to an ASP page to sort out
and display the detail.
The client side code isn't on topic in the asp.db group. The ASP part
is barely on topic for the other groups you posted to. To get the
best answer to your quesion, use the correct groups. And when someone
suggests a different group, follow that advice.
Explain this to me, how will i get the data from the SQL server onto the
page in the first place? will it not need to be an ASP page in order to do
this - then sort out the client options once its there?
Well, umm... Not completely. But that's not an issue. You asked
about the client-side functions, not getting the results from the
database on the server side.

You're new to ASP, and need to understand that an ASP "page" may have
server-side and client-side code, as well as HTML coding, DHTML and
quite possibly a Perl script tacked in for good measure. Just because
you use ASP and the problem appears on the page doesn't mean it's an
ASP issue. Heck, it could be a router, DNS, IIS, authentication, NTFS
permissions or Internet Explorer issue. Each technology has some very
talented people voluntarily helping, but none of us know it all. So
we point you to the best place to resolve your issue.

We don't hate you for it, even though we may sound snotty (answering
the same request a dozen times in a day makes us that way), our real
goal is actually getting you working correctly. If we can also give
you the knowledge to figure it out yourself the next time, even
better.

Jeff
If this is incorrect forgive me, as i stated i am new to ASP and its
sisters.

Please forgive me, as i feel your response was kind of patronising, i
appreciate what you guys do as i frequently answer questions in the Exchange
newsgroups, but your post was simply a point being made rather than helping
me with my query.
Whether client or server side the operation still contains ASP at some
stage, making this post not so as in-appapropriate as you make out.

I will post to the apropriate newsgroups, my apologies to any other MVP with
their knickers in a twist,

Kind Regards

Guy Hocking
MCSE

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:#w**************@tk2msftngp13.phx.gbl...
Guy Hocking wrote:
> Hi there,
>
> I am having a few problems compiling a list box that is conditional
> on what is selected in another list box.
> What i need is a List box (lstArea) that displays one thing when the
> List Box (lstRegion) is selected East or West. Basically the areas
> will change when East or West is selected in lstRegion.
>
> The data comes from an SQL Server view, and my current non-working
> code is as follows, my syntax in the SQL statement is completly
> wrong, i have no idea how to go about this..
> The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the
> new list box (lstArea) to display vchrArea_Name when the List Box
> lstRegion displays vchrLong_Desc.
>


http://www.aspfaq.com/show.asp?id=2270

Bob Barrows

PS. I realize you are new, so you probably are not aware that you've
committed a breach of netiquette here by posting an off-topic question.

Just so you know, ASP is server-side technology, ie, it operates on the

web
server. By the time the client sees anything in the browser, ASP is

usually
finished. All subsequent operations (such as responding to users' actions:
clicking with the mouse or selecting an option in a listbox) are no longer
ASP operations, making them off-topic for this newsgroup. The appropriate
newsgroups for this type of question (client-side code) are those that
contain "dhtml" (dynamic html) in their names, or
microsoft.public.scripting.jscript, or

microsoft.public.scripting.vbscript.
With a few exceptions, questions about activity that occurs on the server
(server-side code) before the client sees the response in the browser, are
the only on-topic questions for these asp newsgroups. (I notice you

included
the .iis newsgroup, which was totally inappropriate, since that newsgroup
deals with the web server itself). It helps to browse a little in the
newsgroups before posting to see which types of questions are deemed
appropriate - you may even discover the answer to your question without
posting. Use Google to seach for answers before posting: you will save
yourself (and us) some time.

I do congratulate you for cross-posting instead of multi-posting, however.
Nothing burns us up more than responding to a question in one newsgroup

only
to find it's been answered in another group.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Jul 19 '05 #6
Try these for starters

http://www.4guysfromrolla.com/webtech/101099-1.shtml

http://www.4guysfromrolla.com/webtech/061399-1.shtml

http://www.devguru.com/features/know...e/A100209.html

http://www.aspfree.com/c/a/ASP/Two-d...taBase-Driven/

"Guy Hocking" <gu*********@bradflack.com> wrote in message news:<#A**************@TK2MSFTNGP09.phx.gbl>...
Hi there,

I am having a few problems compiling a list box that is conditional on what
is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List
Box (lstRegion) is selected East or West. Basically the areas will change
when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working code is
as follows, my syntax in the SQL statement is completly wrong, i have no
idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the new list
box (lstArea) to display vchrArea_Name when the List Box lstRegion displays
vchrLong_Desc.

************************
<select name="lstArea" size="1"><br>
<option value="">Please Select </option>
<%
Dim SQL, RS,

SQL = "SELECT * from vw_SOLS_RegionsAreas_u WHERE
vw_SOLS_RegionsAreas_u.vchrLong_Desc =" ("lstRegion")""

set RS = DataConnection.Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write("<option
value='"&RS("vchrArea_Name")&"'>"&RS("vchrArea_Nam e")&"</option>")
RS.movenext()
wend
else
Response.write("")
end if
%>
</select>
***************************

Hope that is not too confusing,
I am new to ASP so you will have to forgive me for being nieve

Thanks in advance

Guy

Jul 19 '05 #7
Cheers Guys and Gals for your help,

Once again my apologies to those i may of offended.
Keep up the good work ppl

Thanks again

--
Guy
"Alex G" <al************@hotmail.com> wrote in message
news:c5**************************@posting.google.c om...
Try these for starters

http://www.4guysfromrolla.com/webtech/101099-1.shtml

http://www.4guysfromrolla.com/webtech/061399-1.shtml

http://www.devguru.com/features/know...e/A100209.html

http://www.aspfree.com/c/a/ASP/Two-d...taBase-Driven/
"Guy Hocking" <gu*********@bradflack.com> wrote in message

news:<#A**************@TK2MSFTNGP09.phx.gbl>...
Hi there,

I am having a few problems compiling a list box that is conditional on what is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List Box (lstRegion) is selected East or West. Basically the areas will change when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working code is as follows, my syntax in the SQL statement is completly wrong, i have no
idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the new list box (lstArea) to display vchrArea_Name when the List Box lstRegion displays vchrLong_Desc.

************************
<select name="lstArea" size="1"><br>
<option value="">Please Select </option>
<%
Dim SQL, RS,

SQL = "SELECT * from vw_SOLS_RegionsAreas_u WHERE
vw_SOLS_RegionsAreas_u.vchrLong_Desc =" ("lstRegion")""

set RS = DataConnection.Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write("<option
value='"&RS("vchrArea_Name")&"'>"&RS("vchrArea_Nam e")&"</option>")
RS.movenext()
wend
else
Response.write("")
end if
%>
</select>
***************************

Hope that is not too confusing,
I am new to ASP so you will have to forgive me for being nieve

Thanks in advance

Guy

Jul 19 '05 #8

I would suggest using ASP to write out the first select ... then you
will have to use asp to write out the next select for the change in
the first

I would suggest as you explore your javascript needs for this problem,
you make it easy on yourself and look into splitting strings in js

<script language="javascript"
var secondCommaString

switch(valueOfFirstSelectBox)

<%
loop through 1st box variables to get ...

With Response
.Write "case 'firstBoxValue1':" & vbNewLine

.Write "secondCommaString = string of variables for javascript to
use to create an array and create new select bow" & vbNewLine

..Write "break" & vbNewLine
End With
%>

//then later in js split the commaString into a JS array and write
"show" the span and write the 2nd select box with the array of values


Anyway, this is a semi-complex piece of code ... and a little lengthy
for me to put here ...


On Thu, 8 Jan 2004 10:47:17 -0000, "Guy Hocking"
<gu*********@bradflack.com> wrote:
Hi there,

I am having a few problems compiling a list box that is conditional on what
is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List
Box (lstRegion) is selected East or West. Basically the areas will change
when East or West is selected in lstRegion.

The data comes from an SQL Server view, and my current non-working code is
as follows, my syntax in the SQL statement is completly wrong, i have no
idea how to go about this..
The View has 2 columns, vchrLong_Desc and vchrArea_Name, i want the new list
box (lstArea) to display vchrArea_Name when the List Box lstRegion displays
vchrLong_Desc.

************************
<select name="lstArea" size="1"><br>
<option value="">Please Select </option>
<%
Dim SQL, RS,

SQL = "SELECT * from vw_SOLS_RegionsAreas_u WHERE
vw_SOLS_RegionsAreas_u.vchrLong_Desc =" ("lstRegion")""

set RS = DataConnection.Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write("<option
value='"&RS("vchrArea_Name")&"'>"&RS("vchrArea_Na me")&"</option>")
RS.movenext()
wend
else
Response.write("")
end if
%>
</select>
***************************

Hope that is not too confusing,
I am new to ASP so you will have to forgive me for being nieve

Thanks in advance

Guy


Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
2
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold...
12
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
4
by: a | last post by:
I'm having trouble testing a custom object. I've tried many different approaches. One is shown below. The XML below shows the state of the object and I'm trying to test for that state, ie there...
4
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
4
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.