By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

switch or select case and code inside it

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
richard meinte:

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

This discussion thread is closed

Replies have been disabled for this discussion.