Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2004, 01:51 PM
Registered User
 
Join Date: Aug 2004
Location: Memphis, Tennessee, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I restrict options with Select Case

I have inherited some code from someone else, so please bear with me:

We are connecting to an SQL database and using asp code.

function get_title(col_name)
        select case col_name
            case "sel_date"
                get_title = "Entry Date"
            case "sel_zip"
                get_title = "Reporting Zipcode"
                     case "team"
                get_title = "Team"

                end select
end function

Once the selections are made by the user, the query string is constructed just fine.....

The problem is, I want to be able to limit the choices in the drop-down selection based on another field in the database (a Local_ID field).

In other words, I want the choices in the "Team" case to only show the teams associated with "Locale ID 1"...

I keep thinking there should be a where statement but I don't know where to put it or what the proper syntax is.
 
Old August 3rd, 2004, 02:01 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Inside the case, put an If statement
i.e.

function get_title(col_name)
        select case col_name
            case "sel_date"
                get_title = "Entry Date"
            case "sel_zip"
                get_title = "Reporting Zipcode"
            case "team"
                If LocaleID = 1 Then
                   get_title = "Team"
                End If
         end select
end function
 
Old August 3rd, 2004, 02:28 PM
Registered User
 
Join Date: Aug 2004
Location: Memphis, Tennessee, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you sooo much...I'm glad I posted that message. There is no telling how long I would have beat my head against a wall before finding the answer :D

 
Old August 3rd, 2004, 02:55 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Remember between each case you can put as many lines of code as you need.




Similar Threads
Thread Thread Starter Forum Replies Last Post
IE 7 form select options harpua HTML Code Clinic 0 May 9th, 2007 11:59 PM
adding options to a select element dymanicly StevesonD Javascript How-To 0 September 28th, 2006 09:53 AM
Drop Down options to select stream for Listener sam8599 Javascript 0 May 29th, 2006 12:18 PM
Select Options ~ "multiple" attribute phungleon SQL Server 2000 2 July 21st, 2004 10:54 AM
Updating SELECT options list from new window VorlonKen Javascript How-To 4 February 10th, 2004 11:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.