473,725 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

switch or select case and code inside it

I've been tossing around the idea now that maybe my problem might be
better resolved by using the "select case"/switch command.

The only problem is, all the dozens of sites I've seen so far only
give very brief examples using the very basic things.
Such as:

select case name
case "adam"
document.write( "adam")

or what ever.

They might mention that is possible to put code into this statement
but show no examples of this.
Let alone show how to pass a value to the "case" other than by manual
input in the coding.

Assume I have 3 links.
Link 1.
Link 2.
Link 3.

The opening and default is link 1.
User clicks on link 2, what's ever showing in that visible <div 1is
replaced with <div 2>.

How would I best do this?

Nov 4 '08 #1
5 2149
On Nov 3, 11:26*pm, richard <mem...@newsguy .comwrote:
I've been tossing around the idea now that maybe my problem might be
better resolved by using the "select case"/switch command.
A switch statement?

https://developer.mozilla.org/en/Cor...tements/switch
The only problem is, all the dozens of sites I've seen so far only
give very brief examples using the very basic things.
Dozens huh? That must have been frustrating.
Such as:

select case name
case "adam"
document.write( "adam")

or what ever.
Such as what?
>
They might mention that is possible to put code into this statement
but show no examples of this.
How dare they?
Let alone show how to pass a value to the "case" other than by manual
input in the coding.
Other than by what?
>
Assume I have 3 links.
Okay.
Link 1.
Link 2.
Link 3.
Yes, I see them.
>
The opening and default is link 1.
What makes it the default? It looks like the other two to me. None
really look like links at all (not proper links.)
User clicks on link 2, what's ever showing in that visible <div 1is
replaced with <div 2>.
I must have missed divs 1 & 2.
>
How would I best do this?
Start by explaining what you are trying to do.
Nov 4 '08 #2
On Mon, 3 Nov 2008 20:44:57 -0800 (PST), David Mark
<dm***********@ gmail.comwrote:
>On Nov 3, 11:26*pm, richard <mem...@newsguy .comwrote:
>I've been tossing around the idea now that maybe my problem might be
better resolved by using the "select case"/switch command.

A switch statement?

https://developer.mozilla.org/en/Cor...tements/switch
>The only problem is, all the dozens of sites I've seen so far only
give very brief examples using the very basic things.

Dozens huh? That must have been frustrating.
>Such as:

select case name
case "adam"
document.write ("adam")

or what ever.

Such as what?
>>
They might mention that is possible to put code into this statement
but show no examples of this.

How dare they?
>Let alone show how to pass a value to the "case" other than by manual
input in the coding.

Other than by what?
>>
Assume I have 3 links.

Okay.
>Link 1.
Link 2.
Link 3.

Yes, I see them.
>>
The opening and default is link 1.

What makes it the default? It looks like the other two to me. None
really look like links at all (not proper links.)
>User clicks on link 2, what's ever showing in that visible <div 1is
replaced with <div 2>.

I must have missed divs 1 & 2.
>>
How would I best do this?

Start by explaining what you are trying to do.

I just did.

Still, your example does not show how one passes the value to the
{expression}.

<a href="www.googl e.com">Link 1</a>

from your example
switch (expr) {
case "Oranges":
document.write( "Oranges are $0.59 a pound.<br>");
break;

}
how do you get "Oranges" applied to the value in (expr)?

Now can you answer that without the crapola?

Nov 4 '08 #3
On Nov 4, 12:07*am, richard <mem...@newsguy .comwrote:
On Mon, 3 Nov 2008 20:44:57 -0800 (PST), David Mark

<dmark.cins...@ gmail.comwrote:
On Nov 3, 11:26*pm, richard <mem...@newsguy .comwrote:
I've been tossing around the idea now that maybe my problem might be
better resolved by using the "select case"/switch command.
A switch statement?
https://developer.mozilla.org/en/Cor...ference/Statem...
The only problem is, all the dozens of sites I've seen so far only
give very brief examples using the very basic things.
Dozens huh? *That must have been frustrating.
Such as:
select case name
case "adam"
document.write( "adam")
or what ever.
Such as what?
They might mention that is possible to put code into this statement
but show no examples of this.
How dare they?
Let alone show how to pass a value to the "case" other than by manual
input in the coding.
Other than by what?
Assume I have 3 links.
Okay.
Link 1.
Link 2.
Link 3.
Yes, I see them.
The opening and default is link 1.
What makes it the default? *It looks like the other two to me. *None
really look like links at all (not proper links.)
User clicks on link 2, what's ever showing in that visible <div 1is
replaced with <div 2>.
I must have missed divs 1 & 2.
How would I best do this?
Start by explaining what you are trying to do.

I just did.
Coherently.
>
Still, your example does not show how one passes the value to the
{expression}.
What example is that?
>
<a href="www.googl e.com">Link 1</a>

from your example
My example?
switch (expr) {
* *case "Oranges":
* * * document.write( "Oranges are $0.59 a pound.<br>");
* * * break;

}
I've never seen that.
>
how do you get "Oranges" applied to the value in (expr)?
expr = "Oranges";
>
Now can you answer that without the crapola?
Perhaps you should file a complaint.
Nov 4 '08 #4
On Mon, 03 Nov 2008 20:26:11 -0800, richard <me****@newsguy .com>
wrote:
>I've been tossing around the idea now that maybe my problem might be
better resolved by using the "select case"/switch command.

The only problem is, all the dozens of sites I've seen so far only
give very brief examples using the very basic things.
Such as:

select case name
case "adam"
document.write ("adam")

or what ever.

They might mention that is possible to put code into this statement
but show no examples of this.
Let alone show how to pass a value to the "case" other than by manual
input in the coding.

Assume I have 3 links.
Link 1.
Link 2.
Link 3.

The opening and default is link 1.
User clicks on link 2, what's ever showing in that visible <div 1is
replaced with <div 2>.

How would I best do this?


Think I've got this figured out now.
Nov 4 '08 #5
richard meinte:

[snip]
Think I've got this figured out now.
Ooooh, too bad - you were quite entertaining.
Nov 6 '08 #6

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

Similar topics

4
2068
by: JaNE | last post by:
I'm trying to get some data from MySql database and to create switch based on those data, but as an php beginer, I have no clear idea how to do this. have tryed many options which loked promising, but with limited success. here are two versions of code: the 1st one is executing just 1st loaded data, ie: if case is "id_001" it will print "data for id #001", and will, in case there is nothing in url like "index.php?action=" print "nothing"...
19
8101
by: Robert Scheer | last post by:
Hi. In VBScript I can use a Select Case statement like that: Select Case X Case 1 to 10 'X is between 1 and 10 Case 11,14,16 'X is 11 or 14 or 16 End Select
5
10152
by: Neil Zanella | last post by:
Hello, Unlike in pre-C99 versions of C where variables can only be defined at the beginning of blocks, C99 allows variables to be defined in arbitrary places inside blocks. However, gcc 3.2.2 seems to reveal that there are still places where this is illegal. For instance, consider the following code snippet. int main(void) { int i = 0;
11
2203
by: Scott C. Reynolds | last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for truth and execute those statements, such as: SELECT CASE True case x > y: dosomestuff() case x = 5: dosomestuff() case y > x: dosomestuff()
3
19738
by: pgraeve | last post by:
I am a convert from VB to C# so bear with me on this "conversion" question C# switch statement seems to be the closest relative to VB's Select Case. I used VB's Select Case statement liberally. Now I find myself wanting to use "Select Case" i.e., "switch" in C# regularly, but I always have to find another way b/c C#'s switch statement only allows static or integral variables. For example, I often want to use a switch statement based on the...
16
19051
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test 1"); break;
14
13055
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; int main() { int i;
2
2882
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of various module that I found it useful. Here is the 1st problem I encounter: I had a function to edit a event row form the database which is fine with me, than I pass on the code to a function that save(update) the data to the database.
7
3360
by: Rohit | last post by:
Hi, I am working on a switch module which after reading voltage through a port pin and caterogizing it into three ranges(open,low or high), passes this range to a function switch_status() with parameters value and signal ID. Signal Id is used to get a user configurable parameter inside a configuration file, which depends on the type of switch. I have implemented it as under. Please ignore those magic numbers as I have mimized logic to...
0
8752
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
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

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.