Wrox Programmer Forums
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 September 18th, 2004, 05:19 AM
Registered User
Join Date: Aug 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP switch(variable){} and case:


I am using javascript to code some ASP pages. So far so good however, I have come across an interesting piece of behaviour regarding switch (variable) between client side and serverside ASP.

switch (typeRes)
     case "red":
     case "blue":
works in a client side script. however, I am trying to use a similar construct in a form validation script on a page that uses ASP/SQL to generate the contents. In this case the default is selected everytime.

Any suggestions.

Head of innovation and Industry Services,
Faculty of Applied Arts
Old September 18th, 2004, 08:38 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

Not exactly sure what you specific problem is. The above code is JS, does this code run error free? The reason I ask is the three lines with trailing coluns, shouldnt these be semi coluns?

;;;"I am trying to use a similar construct in a form validation script on a page that uses ASP/SQL to generate the contents. In this case the default is selected everytime."

The function you havnt posted is the one where the problem is? If this is the case post the problem function would be better.

I dont believe ASP/VBScript has a switch function, the select case is probably what you are after:

Sub ChangeBackground (Color)
   MyVar = lcase (Color)
   Select Case MyVar
      Case "red"
      Case "green"
      Case "blue"
      Case Else
   End Select
End Sub

Wind is your friend
Old September 18th, 2004, 08:39 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post


How about posting the code that doesn't work? That would help us understand what you are trying to achieve.

- Vijay G
Strive for Perfection
Old September 18th, 2004, 09:05 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts

Where does the variable typeRes come from? How do you create it?

-Snib <><
There are only two stupid questions: the one you don't ask, and the one you ask more than once :-)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch Case statements ermy78 Access VBA 3 October 20th, 2006 08:58 AM
Setting a variable using Select Case Adam ASP.NET 1.0 and 1.1 Basics 2 September 4th, 2004 02:09 PM
case switch thtrance BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 August 26th, 2004 02:36 AM
search string either Upper case or lower case rylemer Beginning VB 6 3 March 24th, 2004 04:23 PM
Check Case in a Case-Insensitive DB nbryson SQL Language 1 January 23rd, 2004 07:36 AM

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