|
Actually, in MX the CFScript version of switch
allows you to stack multiple case values and uses the break command. This
makes it much more powerful than CFSwitch and gives you all the features of the
JS switch statement.
switch(arraylen(arguments)) {
case "1": argument2 =
yadda;
case "2": argument3 = yadda;
break;
case "3": case "4": argument1 =
yadda;
}
Kevin
----- Original Message -----
Sent: Monday, January 26, 2004 11:43
AM
Subject: Re: _javascript_
That works with CF in CFScript also... I like to use it with
functions sometimes for the number of arguments:
switch
(arraylen(arguments)) { case "1": { argument2 = yadda; } case "2": {
argument3 = yadda; } default: { yadda; } }
Makes it a little
easier than having multiple comparisons of the number of
arguments.
The delimitered case statements are a bit different -- you
can't have the same value in two case blocks, so for instance you can't
say:
<cfcase value="1"></cfcase> <cfcase
value="1,2"></cfcase>
Delimiters are nice, but they still
don't allow quite the same functionality as the cfscript switch statement
(granted, you don't get delimiters in cfscript either, so there are pros
and cons either way). Personally I think it would have been nice if they'd
provided a way of allowing the tag-based case statements to cascade,
like
<cfswitch cascade="true"> <cfcase
value="1"> blah blah blah
<cfbreak> </cfcase> <cfcase
value="2"></cfcase> <cfcase
value="3"></cfcase> </cfswitch>
Which would allow you
to get the same functionality from a tag-based switch. But it's such a
"one-off" feature (so infrequently mentioned) I doubt it'll ever be
implemented.
> Might be a little easier to read with a
select/case ;) > It works just like the CF one, except you
need to use a > break statement where you want it to stop
processing. > (pretty powerful that way - can have multiple case
blocks > cascade)
> function checkCCAccount(Ticket)
{ > var pmt =
Ticket.PaymentType.options[Ticket.PaymentType >
.selectedIndex].value; >
switch(pmt){ > case
1: > alert(pmt + "You must enter the
account information > if you are
paying by Corporate Check"); >
break; > case 3: case 4: case 5: case
6: > alert(pmt + "Please note that
your credit card will > be process
at the time of the service call"); >
break; > } > }
> a lot of
people dont realize you can do the same thing in > cold fusion - have a
multiple values for a single > case statement with delimiters in
it. i.e. -
> <cfswitch
_expression_="#myValue#"> > <cfcase
value="1,2"> >
<!--- for values 1, 2 ---> > </cfcase> >
<cfcase
value="3,4,5,6"> >
<!--- for values 3, 4, 5, 6 ---> >
</cfcase> > </cfswitch>
> just a tid bit
that gets overlooked a lot it seem, so > worth mentioning
:)
> -Nate > ----- Original Message
----- > From: Bruce Sorge > To: [EMAIL PROTECTED] > Sent:
Saturday, January 24, 2004 3:59 PM > Subject:
_javascript_
> Ahh. My arch nemesis, _javascript_. I am
having issues > with this piece of
code:
> function checkCCAccount(Ticket)
{ > Pmt =
Ticket.PaymentType.selectedIndex > if
(Ticket.PaymentType.options[Pmt].value == 1);
{ >
alert(Ticket.PaymentType.options[Pmt].value +
"You > must enter the account
information if you are paying > by
Corporate Check"); >
} > else if
(Ticket.PaymentType.options[Pmt].value ==
3); >
{ >
alert(TIcket.PaymentType.options[Pmt].value
+ > "Please note that your credit
card will be process > at the time
of the service call"); >
} > else if
(Ticket.PaymentType.options[Pmt].value ==
4); >
{ >
alert(TIcket.PaymentType.options[Pmt].value
+ > "Please note that your credit
card will be process > at the time
of the service call"); >
} > else if
(Ticket.PaymentType.options[Pmt].value ==
5); >
{ >
alert(TIcket.PaymentType.options[Pmt].value
+ > "Please note that your credit
card will be process > at the time
of the service call"); >
} > else
(Ticket.PaymentType.options[Pmt].value == 6);
{ >
alert(TIcket.PaymentType.options[Pmt].value
+ > "Please note that your credit
card will be process > at the time
of the service call"); >
} > }
> I keep getting a
syntax error. Any takers?
>
Thanks,
>
Bruce
>
-------------------------------------------------- >
----------------------------- >
This message was processed by Mail
Filter >
Extension > http://sssolutions.net/mf/ >
-------------------------------------------------- >
-----------------------------
s. isaac
dealey
214-823-9345
team macromedia volunteer http://www.macromedia.com/go/team
chief
architect, tapestry cms http://products.turnkey.to
onTap
is open source http://www.turnkey.to/ontap
----------------------------------------------- To
post, send email to [EMAIL PROTECTED] To unsubscribe:
Send UNSUBSCRIBE to [EMAIL PROTECTED] To
subscribe / unsubscribe: http://www.dfwcfug.org
|