Jump to content

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!



var P1=1


var P2=1


var P3=1


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]))
   return count;

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

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...