I am trying to hide the 'div' by checking if a label is empty. But Something went wrong. Below is the code I used.
<script>
function myfun(){
if (document.getElementById('department').innerHTML=='') {
document.getElementById('departmentdiv').style.display="none";
}
}
</script>
<body onload="myfun()">
<div id="departmentdiv" class="row-fluid">
<label>DEPARTMENT:</label>
<label id="department"><?php if (!empty($_POST['department']))echo $_POST['department'];?></label>
</div>
</body>
I am getting the POST[department] value from the a different page and assigned it to the label in this page. I want to show the div only if the value is not null. But, the problem is label doesn't show at all on this page even if its not null. Does anybody can help me out