getajobnowbiz Posted January 21, 2016 Report Share Posted January 21, 2016 There is a table contains 5 file fields that users can submit files (images) to our table. In the report form (details page), I set 5 html blocks to display them one by one with responsive tag (width=70%) and they displayed finally and responsively. I showed them in this way. <img src "URL" width=70%"/> However there is a problem comes. I need some JavaScript code to check and decide if I execute this html code. Otherwise there is a img icon showed if there is empty in that field If there is a file, it will be executed. If there is empty, it will not be executed. Could anybody help Thanks. Sam Quote Link to comment Share on other sites More sharing options...
Xiang Posted January 21, 2016 Report Share Posted January 21, 2016 Hi Sam, How are you doing? I think, you can insert the following code to your HTML Blocks: <script> var firstfield = '[@field:file1]'; if(firstfield.length>0) document.write("<img src='[@field:file1/]' width=70%/>"); else document.write("<img src='DEFAULT URL' width=70%/>"); </script> Insert your field instead of both [@field:file1] . For me, it's better to use a Parameter picker and use the String format for the first line, and "File URL" for the "document.write" line. I will be glad to hear if the code works or help, if it does not Quote Link to comment Share on other sites More sharing options...
getajobnowbiz Posted January 21, 2016 Author Report Share Posted January 21, 2016 Thanks Xiang I did it 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.