WEIGHT-10 [Javascript] switch/ case activating

Peter Brunone peter at brunone.com
Wed Feb 9 15:54:20 CST 2005


Hi Richard,

   You may be over-analyzing this.  If you have strings to compare, you just stick 'em in there.

switch(myStringValue) {
 case "planes":
  alert("It's planes!!!");
  break;
  }

   On the other hand, if you're expecting that switch variable to be the ID of the appropriate element, you might not even need a switch statement (i.e. you'd just feed the value into your document.getElementById method and go).

Cheers,

Peter

 From: "Richard " nomorebull at charter.net

Ok I understand all the basics of the switch/case item.
Basically a more structured "if" array.

My problem is, understanding how to activate it.
In my menu of , which could be quite long, where and how do you state
what "case" is to be a certain value?"
I plan using string literals, such as "planes", "trains" and that.
For instance:

Do I trigger the function with getelementybyID routine or what?

If anyone can come with a short example as to how to do this, I'd appreciate
it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050209/875f134e/attachment.htm>


More information about the Javascript mailing list