EricC Posted January 12, 2009 Share Posted January 12, 2009 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? Quote Link to comment Share on other sites More sharing options...
Jeff Berry Posted September 17, 2011 Share Posted September 17, 2011 Hi Eric, I know its been almost three years since this was posted but did you ever find a way to accomplish this? Thanks, Jeff Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 20, 2011 Share Posted September 20, 2011 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"); Quote Link to comment Share on other sites More sharing options...
esmith Posted September 21, 2011 Share Posted September 21, 2011 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. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 21, 2011 Share Posted September 21, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.