Jump to content

Photo vs. No Photo on a business card


EricC

Recommended Posts

I have a business card I want to upload to my printOne site.

 

There are two versions of the business card - one with a photo, and one WITHOUT.

 

I need to write a rule that does the following:

 

If the website user has uploaded a picture, then SUPPRESS a text box.

 

The user can upload his/her photo (optional)

OR

The user can enter some text.

 

The text will appear in the same location as the photo, so it's an "either / or" thing ... if the customer uploads a photo then EVEN IF he/she enters some text into this field, the text is suppressed BECAUSE the user uploaded a photo.

 

make sense?

 

I already know how to write an if/then statement that says:

if 'something' = 'x' then return ""; (i.e. return nothing)

 

but can that 'something' be a photo that the customer has uploaded?

Link to comment
Share on other sites

  • 2 years later...

Just place a graphic frame and a text frame in the same position, and have each one populate whatever it has. The empty one won't show up. You can write a rule like this for the text frame:

if (Field("YourGraphicField"))
   return "";
//else
return Field("YourTextField");

Or, you could name the text frame and do this in OnRecordStart:

FindTextFrame("TextFrameName").suppress[b] = [/b]!!Field("YourGraphicField");

Link to comment
Share on other sites

Or, you could name the text frame and do this in OnRecordStart:

FindTextFrame("TextFrameName").suppress[b] = [/b]!!Field("YourGraphicField");

Can you explain what the double exclamation is doing in layman's terms? I googled it and read about booleans and double inverting, but I'm not getting how that is being applied in this example.

Link to comment
Share on other sites

Can you explain what the double exclamation is doing in layman's terms? I googled it and read about booleans and double inverting, but I'm not getting how that is being applied in this example.

The ! (not) operator converts its operand to a Boolean (true/false) value. In JavaScript, anything can be converted to Boolean. In this case, the Field function always returns a String, and the rules for converting a string to Boolean state that an empty string becomes False, and a non-empty string becomes True. The second ! (not) operator inverts the value, so that if the original operand is empty, you get False. Basically the !! operator on a string is asking: Is the string non-empty? And by extension, is the field value non-empty? If so, we suppress the frame.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...