Heineperson Posted May 22, 2018 Report Share Posted May 22, 2018 Hello, I'm currently using document.write in a report datapage to create conditional formatting in an HTML block column. (See last column of this link). I am having an error wherein the second page of the report omits the last column. I asked caspio support and they said it is may be because I am using document.write, which is no longer supported in the new upgrade. They suggested using innerHTML, alert(), but I'm not sure how to modify the code. Any advice? Also, Is it possible that document.write is not the problem? <script> if ("[@field:tblRareTaxonTable_ProfileStatus]" == "Active") { document.write("<div style='background:#A0CE4E;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><strong><a href='https://saveplants.org/national-collection/plant-search/plant-profile/?CPCNum=[@field:tblRareTaxonTable_CPCNumber]' <span style='color:#482441;'>Go To Profile</span></a></strong></span></div>"); } else { document.write("<div style='background:#482441;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><span style='color:#FFFFFF;'><strong>Profile In Progress</strong></span></span></div>"); } </script> Thanks so much for your help! Katie Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted May 22, 2018 Report Share Posted May 22, 2018 Hi @Heineperson, You can try following code with inner HTML: <div id='record[@cbRecordIndex#]'></div> <script type="text/javascript"> debugger; document.addEventListener('DataPageReady', function (event) { if ("[@field:tblRareTaxonTable_ProfileStatus]" == "Active") { document.write("<div style='background:#A0CE4E;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><strong><a href='https://saveplants.org/national-collection/plant-search/plant-profile/?CPCNum=[@field:tblRareTaxonTable_CPCNumber]' <span style='color:#482441;'>Go To Profile</span></a></strong></span></div>"); } else { document.write("<div style='background:#482441;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><span style='color:#FFFFFF;'><strong>Profile In Progress</strong></span></span></div>"); } }); </script> Hope this helps. Regards, vitalikssssss Heineperson 1 Quote Link to comment Share on other sites More sharing options...
Heineperson Posted July 19, 2018 Author Report Share Posted July 19, 2018 Thanks for your help @Vitalikssssss! I'm so sorry for the slow reply-I was moved to another project for a few months, and am now getting back to this. Do you mean I should replace document.write with innerHTML in the code above? Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted July 20, 2018 Report Share Posted July 20, 2018 Hi @Heineperson, Sorry, I forgot to add inner HTML in my code. Please try to use the following code: <div id='record[@cbRecordIndex#]'></div> <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if ("[@field:tblRareTaxonTable_ProfileStatus]" == "Active") { document.getElementById("record[@cbRecordIndex#]").innerHTML="<div style='background:#A0CE4E;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><strong><a href='https://saveplants.org/national-collection/plant-search/plant-profile/?CPCNum=[@field:tblRareTaxonTable_CPCNumber]' <span style='color:#482441;'>Go To Profile</span></a></strong></span></div>"; } else { document.getElementById("record[@cbRecordIndex#]").innerHTML="<div style='background:#482441;border:1px solid #000000;padding:5px 10px;'><span style='font-size:16px;'><span style='color:#FFFFFF;'><strong>Profile In Progress</strong></span></span></div>"; } }); </script> Regards, vitalikssssss Heineperson 1 Quote Link to comment Share on other sites More sharing options...
Heineperson Posted July 20, 2018 Author Report Share Posted July 20, 2018 THANK YOU @Vitalikssssss! This worked perfectly!!! 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.