473,545 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Regions Areas_u WHERE
vw_SOLS_Regions Areas_u.vchrLon g_Desc =" ("lstRegion" )""

set RS = DataConnection. Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write( "<option
value='"&RS("vc hrArea_Name")&" '>"&RS("vchrAre a_Name")&"</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 1861
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.publi c.scripting.jsc ript, or microsoft.publi c.scripting.vbs cript.
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******@NOyah oo.SPAMcom> wrote in message
news:#w******** ******@tk2msftn gp13.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.publi c.scripting.jsc ript, or microsoft.publi c.scripting.vbs cript. 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
"profession al" 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*********@br adflack.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*********@br adflack.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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_Regions Areas_u WHERE
vw_SOLS_Regions Areas_u.vchrLon g_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.Fo rm("DropDown1") )

If DropDown1 <> "" Then
sSQL = "SELECT * FROM vw_SOLS_Regions Areas_u WHERE sw_etc = '" &
DropDown1 & "'"
Set RS = DataConn.Execut e(SQL)
If NOt (RS.eof and RS.BOF) Then
Response.write "<Select name = ""DropDown2 "">"
Do While Not Rs.Eof
Response.write "<option value = """ & RS("WhichEverID Field") &
""">" & RS("WhichEverTe xtField
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("vc hrArea_Name")&" '>"&RS("vchrAre a_Name")&"</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*********@br adflack.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******@NOyah oo.SPAMcom> wrote in message
news:#w******* *******@tk2msft ngp13.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.publi c.scripting.jsc ript, or

microsoft.publ ic.scripting.vb script.
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*********@br adflack.com> wrote in message news:<#A******* *******@TK2MSFT NGP09.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_Regions Areas_u WHERE
vw_SOLS_Regions Areas_u.vchrLon g_Desc =" ("lstRegion" )""

set RS = DataConnection. Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write( "<option
value='"&RS("vc hrArea_Name")&" '>"&RS("vchrAre a_Name")&"</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.goo gle.com...
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*********@br adflack.com> wrote in message

news:<#A******* *******@TK2MSFT NGP09.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_Regions Areas_u WHERE
vw_SOLS_Regions Areas_u.vchrLon g_Desc =" ("lstRegion" )""

set RS = DataConnection. Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write( "<option
value='"&RS("vc hrArea_Name")&" '>"&RS("vchrAre a_Name")&"</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="javas cript"
var secondCommaStri ng

switch(valueOfF irstSelectBox)

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

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

.Write "secondCommaStr ing = 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*********@br adflack.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_Des c.

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

SQL = "SELECT * from vw_SOLS_Regions Areas_u WHERE
vw_SOLS_Region sAreas_u.vchrLo ng_Desc =" ("lstRegion" )""

set RS = DataConnection. Execute(SQL)
If not RS.EOF then
while not RS.EOF
Response.write( "<option
value='"&RS("v chrArea_Name")& "'>"&RS("vchrAr ea_Name")&"</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
3499
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 in a list box and submits the form the value is put into a session variable and the relevant page is displayed (in accordance to one of the list...
3
5921
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 terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both...
13
6070
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 during production. Usually, this only wraps code used to control quitting the whole app versus just shutting a form, but it can also control many...
2
1190
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 when the date has passed. Background: I have 2 related fields that are only rarely active, so I manage them in the query for the subform:...
12
2468
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 main()
2
2339
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 on. I have a second table that contains a list of tasks to be performed and relates to the Case_List through a Case_ID. So currently, I can...
4
1917
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 are NO classes in the Classes collection (Classes) of the custom object. The conditional expression returns the error shown below it... ...
4
2793
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. Feature1=true,Feature2=false, ... VS2005 seems to either allow the existance of the constant or not. ie. You must omit a constant not declare it to be false ...
4
8927
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 textbox background to display yellow, else I want it to be just white. Here's my code... but it is not working Private Sub Form_Load() If Me!STATUS =...
0
7411
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.