Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] select-case construct (amended)
- From: javascript@xxxxxxxxxx (Mark Christie)
- Subject: [Javascript] select-case construct (amended)
- Date: Mon, 29 Oct 2001 15:23:53 -0600
Yes. :^)
Either add an ending } before the else clause:
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
}
or get rid of the beginning { after the if condition:
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
}
Regards,
-Mark C.
-----Original Message-----
From: Esther_Strom@xxxxxxxx [mailto:Esther_Strom@xxxxxxxx]
Sent: Monday, October 29, 2001 2:51 PM
To: javascript@xxxxxxxxxx
Subject: RE: [Javascript] select-case construct (amended)
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
- Prev by Date: [Javascript] select-case construct (amended)
- Next by Date: [Javascript] select-case construct (amended)
- Previous by thread: [Javascript] select-case construct (amended)
- Next by thread: [Javascript] select-case construct (amended)
- Index(es):