SNMCStrategicSupport Posted April 26, 2017 Report Share Posted April 26, 2017 I'm trying to hide a tabular report if a given comparison returns as false. I have the below code that works to hide the table no matter the result: <script language="javascript" type="text/javascript"> function hide_column(column_order) { var tbl = document.getElementsByTagName("table")[0]; var table_header = tbl.getElementsByTagName('th')[column_order]; table_header.style.display=stl; var rows = tbl.getElementsByTagName('tr'); for (var row=1; row<rows.length;row++) { var cels = rows[row].getElementsByTagName('td'); cels[column_order].style.display=stl; } } var stl='none'; hide_column(0); hide_column(1); hide_column(2); hide_column(3); hide_column(4); hide_column(5); hide_column(6); </script> However, If I'm adding a restriction var string = "[@authfield:Authentications_2_Region]", substring = "[@field:Location_2_Region_GL]"; if(string.includes(substring)=false) I don't know where to put it; I've tried putting it everywhere and can't get it to work right. Full disclosure: I'm not good with Javascript and may be way off the mark on the formatting...I'm trying to piece this together with W3 Schools and Google. Quote Link to comment Share on other sites More sharing options...
SNMCStrategicSupport Posted April 27, 2017 Author Report Share Posted April 27, 2017 In case someone stumbles across this, I was able to get the solution to work using this string of code: <script language="javascript" type="text/javascript"> function hide_column(column_order) { var str = '[@authfield:Authentications_2_Region]'; var n = str.indexOf('[@field:Location_2_Region_GL]'); if(n < 0){ var tbl = document.getElementsByTagName("table")[0]; var table_header = tbl.getElementsByTagName('th')[column_order]; table_header.style.display=stl; var rows = tbl.getElementsByTagName('tr'); for (var row=1; row<rows.length;row++) { var cels = rows[row].getElementsByTagName('td'); cels[column_order].style.display=stl; } } } var stl='none'; hide_column(0); hide_column(1); hide_column(2); hide_column(3); hide_column(4); hide_column(5); hide_column(6); </script> 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.