Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] select-case construct (amended)


  • From: javascript@xxxxxxxxxx (javascript@xxxxxxxxxx)
  • Subject: [Javascript] select-case construct (amended)
  • Date: Mon, 29 Oct 2001 15:27:34 -0600

Duh! I've been staring at this too long; thanks for catching that.

Esther


                                                                                                                       
                    "Dylan Parker"                                                                                     
                    <dylan@mindstech.        To:     <javascript@xxxxxxxxxx>                                           
                    com>                     cc:                                                                       
                    Sent by:                 Subject:     RE: [Javascript] select-case construct (amended)             
                    javascript-admin@                                                                                  
                    LaTech.edu                                                                                         
                                                                                                                       
                                                                                                                       
                    10/29/01 03:18 PM                                                                                  
                    Please respond to                                                                                  
                    javascript                                                                                         
                                                                                                                       
                                                                                                                       




It looks like your syntax for if/else statements is incorrect..

You have

           if(...) {
             ...
           else {
             ...
           }
           }


and it should be

           if(...) {
             ...
           } else {
             ...
           }

See the difference?

Dylan Parker


> Thanks to both of you for your help. Now another question: is there any
> reason I can't use an if/else inside a case?
>
>
> This works:
>
> switch(selStatus){
>                case "Image from Design":
>                     if(document.forms[0].toDesign.value==""){
>                          document.forms[0].toDesign.value=todayDate;
>                     break master
>                     }
>
>
> This doesn't:
>
> switch(selStatus){
>                case "Image from Design":
>                     if(document.forms[0].toDesign.value==""){
>                          document.forms[0].toDesign.value=todayDate;
>                     else {
> document.forms[0].toDesign.value=document.forms[0].toDesign.value + "," +
> todayDate;
>                     }
>                     break master
>                     }
>
> It's fine until I add the "else"; then it causes a syntax error. Am I
> missing something really obvious here?
>
> Thanks,
>
> Esther
>
>
>
>
>                     "Filipiak, Bob
>
>                     (Contractor)"            To:
> "'javascript@xxxxxxxxxx'" <javascript@xxxxxxxxxx>
>                     <filipiab@xxxxxxx        cc:
>
>                     my.mil>                  Subject:     RE:
> [Javascript] select-case construct (amended)
>                     Sent by:
>
>                     javascript-admin@
>
>                     LaTech.edu
>
>
>
>
>
>                     10/29/01 02:11 PM
>
>                     Please respond to
>
>                     javascript
>
>
>
>
>
>
>
>
>
> switch expr {
>    CASE label:
>    ....
> }
>
>
> should work for NS 4.x and above according to my "Pure JavaScript."
>
>
>
>
>
> Bob Filipiak
> (Contractor)
>
>
>
>
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: Esther_Strom@xxxxxxxx [mailto:Esther_Strom@xxxxxxxx]
> Sent: Monday, October 29, 2001 3:00 PM
> To: javascript@xxxxxxxxxx
> Subject: [Javascript] select-case construct (amended)
>
>
>
>
>
> Forgot to mention...this needs to work in NS4.7 for PC and Mac.
>
>
> Thanks.
> ----- Forwarded by Esther Strom/McDougal/hmco on 10/29/01 01:58 PM -----
>
>                     Esther Strom
>
>                                          To:     javascript@xxxxxxxxxx
>
>                     10/29/01             cc:
>
>                     01:58 PM             Subject:     select-case
> construct
>
>
>
>
>
>
>
>
> I'm sure this has been mentioned before, but I can't find the
> message or an
>
> example in any of my books. Can you use a select-case construct in
> javascript?
>
>
> Pseudocode example:
>
>
> select case prodStatus
>
>
> Case "New"
> //do this
>
>
> Case "In Progress"
> //do this
>
>
> Case else
> //do this
>
>
> End select
>
>
> Thanks for any help available.
>
>
> Esther
>
>
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> http://www.LaTech.edu/mailman/listinfo/javascript
>
>
>
>
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> http://www.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript@xxxxxxxxxx
http://www.LaTech.edu/mailman/listinfo/javascript