Jump to content
  • 0

Is It Possible To Hide The Part Of A Text In An Html Block, If A Parameter Is Empty?



Hi everyone!


I have an HTML block, where I want to display parameters like follows:


Author: [@field:author], Coauthor:[@field:coauthor]


But the [@field:coauthor] parameter is empty often.


Is it possible to display the ", Coauthor:[@field:coauthor]" part only if a coauthor is exist?


Thank you for your time!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello Cameron,


If I understand correctly, you can use a JavaScript code.

Please select your "HTML Block", click the "Source" button, delete the current text and enter the following code:

Author: [@field:author]
<script language="javascript">
var coauthor='[@field:coauthor]';
if (coauthor.length>0)
coauthor = ", Coauthor: "+coauthor;

Also I would recommend you to disable AJAX on the DataPage.

You can open the "Results Page Options" step and uncheck the "Enable AJAX" checkbox.


I hope, it helps.

Link to comment
Share on other sites

  • 0


Just to update, if [@field:coauthor] is blank, there's another way to hide Coauthor. You can also use SQL Formula instead of script.

In Submission Form/ Details, you can add virtual field and use Calculated Value as Form Element. 

CASE WHEN [@field:coauthor] ='' THEN '' ELSE 'Coauthor:[@field:coauthor]' END


Then, you can display the result of this Virtual field in the HTML Block. 


Hope this helps!

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.

Answer this question...

×   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...