Cameron Posted July 14, 2015 Report Share Posted July 14, 2015 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! Quote Link to comment Share on other sites More sharing options...
0 Jan Posted July 14, 2015 Report Share Posted July 14, 2015 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; document.write(coauthor); } </script> 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. Quote Link to comment Share on other sites More sharing options...
0 Cameron Posted July 14, 2015 Author Report Share Posted July 14, 2015 Hi Jan, Yes, it helped! Thank you for your time! Quote Link to comment Share on other sites More sharing options...
0 cheonsa Posted August 28, 2021 Report Share Posted August 28, 2021 Hello! 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! Quote Link to comment Share on other sites More sharing options...
0 IamNatoyThatLovesYou Posted September 12, 2021 Report Share Posted September 12, 2021 Hi everyone, they also have a documentation that you can refer to. You can check it here. -Natoy Quote Link to comment Share on other sites More sharing options...
Question
Cameron
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
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.