Jump to content
Welcome to the new FusionPro User Forum! ×

Choose graphic via number of fields occupied


Recommended Posts

I have four fields and a graphic that depends on how many of the four fields have data (not empty). The following code always returns "EL_BC_1Lines.pdf" regardless. I don't seem to be adding the variables correctly. Perhaps there is a better way overall?

 

I have a client pressing for a result!

 

if(Field("Phone1")!="")

var P1=1

if(Field("Phone2")!="")

var P2=1

if(Field("Phone3")!="")

var P3=1

if(Field("Phone4")!="")

var P4=1

var PT=P1+P2+P3+P4

if (PT=1)

return Resource("EL_BC_1Lines.pdf");

if (PT=2)

return Resource("EL_BC_2Lines.pdf");

if (PT=3)

return Resource("EL_BC_3Lines.pdf");

if (PT=4)

return Resource("EL_BC_4Lines.pdf");

Link to comment
Share on other sites

I would do this:

function CountNonEmptyFields()
{
   var count = 0;
   for (var i = 0; i < arguments.length; i++)
   {
       if (Field(arguments[i]))
           count++;
   }
   return count;
}

var count = CountNonEmptyFields("Phone1", "Phone2", "Phone3", "Phone4");
return Resource("EL_BC_" + count + "Lines.pdf");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...