Here is one option...
switch(Field("Phone")==""?1:0+ Field("Fax")==""?1:0+ Field("Email")==""?1:0)
{ // break omitted because of return statements.
case 0: return Field("Fax") + "<br>" + Field("Phone") + "<br>" +
Field("Email"); case 3: return "";default: return Field("Phone") + "<br>" +
Field("Fax") + "<br>" + Field("Email")} 

Great for job security, sort of, but there are better options.  You have
your logic composed well, so converting is easy.

"If" statements look like this

        if (true/false) {do if true}
or
        if (true/false) {do if true} else {do if false}

(technically the { and } could be omitted here, but it doesn't hurt to
include them, so I would until you are comfortable)
        if (Field("Phone")=="") {var1 = 0} else {var1 = 1};

Wash, rinse, repeat.

Remember to add a line like
        sum = var1 + var2 + var3;

You have two options for the second part of your logic.  You can continue
with the if statements, or you can take a look at the switch statement.
        switch (compare_value) {
                case value1: statement(s); break;
                case value2: statement(s); break;
                default: statement(s)
        }

The break tells the script to jump to the end of the switch statement,
otherwise the code for all remaining case statements (or until a break is
reached) will be run.  If you are using "return", it is okay to omit the
break because you are leaving the function/rule at that point.  Value1,
value2, etc., tell the script to start at this point if the compare_value is
equal to it.  If more than one case statement has a given value, then only
the first will be matched.  Default is what is used if nothing matched the
compare_value.

switch(sum) { 
        case 0: return Field("Fax") + "<br>" + Field("Phone") + "<br>" +
Field("Email"); 
                break;
        case 3: return "";
                break;
        default: return Field("Phone") + "<br>" + Field("Fax") + "<br>" +
Field("Email")
}

Cheers.

-----Original Message-----
From: Nicola DosSantos [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 19, 2007 6:25 AM
To: FusionPro Users Forum
Subject: [fusionpro] HELP - Does anyone know how to write this equation in
JavaScript????

Good Morning Everyone,

I'm working with a total of 6 variables and depending on how many contain
something the order in which they appear will change. In theory what I have
below should work, but my code writing skills are still so basic that I'm
unsure how to formally write it in JavaScript.I was hoping that someone
could help me write the below sample equation in Javascript. Thanks in
advance for any suggestions!!

if phone contains nothing,
    var1 = a number value of "0"
if phone contains something,
    var1 = a number value of "1"

if fax contains nothing,
    var2 = a number value of "0"
if fax contains something,
    var2 = a number value of "1"

if email contains nothing,
    var3 = a number value of "0"
if pemail contains something,
    var3 = a number value of "1"

if the sum of (var1 + var2 + var3) is = = 1 or 2
    return phone + "<br>" + fax + "<br>" + email;

if the sum of (var1 + var2 + var3) is = = 3
    return fax + "<br>" + phone + "<br>" + email;

if the sum of (var1 + var2 + var3) is = = 0
    return " ";

--
Nicola DosSantos

Ambit Press / Minuteman Press of Cambridge Five Cambridge Center Cambridge,
MA 02142
Tel: 617.876.3688
Fax: 617.876.3896
www.ambitpress.com

Please send all jobs to [EMAIL PROTECTED]



+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Calling all FP Web Users!

Do you have a question or lots of knowledge to share about FusionPro Web?

If so, join our Printable Web to Print Users' Forum today!

Send email to [EMAIL PROTECTED] to find out how! 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


--
Users of FusionPro Desktop have unlimited free email support. Contact
Printable Support at [EMAIL PROTECTED] 
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise
recorded by the e-mail recipients of this forum. It is subject to archival,
monitoring or review by, and/or disclosure to someone other than the
recipient. Our privacy policy is posted on www.printplanet.com
--





+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 
Calling all FP Web Users!

Do you have a question or lots of knowledge to share about FusionPro Web?

If so, join our Printable Web to Print Users' Forum today!

Send email to [EMAIL PROTECTED] to find out how! 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


--
Users of FusionPro Desktop have unlimited free email support. Contact Printable 
Support at [EMAIL PROTECTED] 
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise 
recorded by the e-mail recipients of this forum. It is subject to archival, 
monitoring or review by, and/or disclosure to someone other than the recipient. 
Our privacy policy is posted on www.printplanet.com
--

Reply via email to