473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2115
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.google.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.google.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
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,...
19
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
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...
11
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 >...
3
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. ...
16
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...
14
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; int main() { int i;
2
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...
7
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...

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.