hide badge counter if zero
Posted: 2021-07-23 15:40
once again my lack of talent has forced me to ask for some help. I have 3 tiles on the homepage (index.php) which show the number of open records that still need attention. (records are closed by simply selecting "yes" as a radio button option). Is there a simple way to hide a badge that is either empty (ie there are no records at all) OR has all records closed? In my header-extras I currently have:
I thought something like this (please don't laugh) would work, but doesn't:
Code: Select all
<?php
$var = sqlValue("SELECT count(1) FROM mytable WHERE record_closed = 'No'");
?>
<script>
jQuery(function () {
$j('#mytable-tile').find('.badge').text('<?php echo $var ?>');
})
</script>
I thought something like this (please don't laugh) would work, but doesn't:
Code: Select all
<?php
$var = sqlValue("SELECT count(1) FROM mytable WHERE record_closed = 'No'");
?>
<script>
jQuery(function () {
if ($var = 0) {
$j('#mytable-tile').find('.badge').hide();}
else {
$j('#mytable-tile').find('.badge').text('<?php echo $var ?>')}
});
</script>
[code]