I've got some code that is meant to hide a div in HTML if a variable is empty.
Sub checkBattery
If IsEmpty(e("batremaining")) Then
batteryShow.style.visibility = "hidden"
Else
batteryShow.style.visibility = "visible"
End If
End Sub
checkBattery
This is extremely frustrating me, because I have no idea why it is not working.
Here is my <div>
:
<div id="batteryShow" class="panel panel-warning batteryShow">
<div class="panel-heading">
<h3 class="panel-title">Battery Percentage</h3>
</div>
<div class="panel-body">
<center><div style="font-size:16px;font-weight:bold;">Battery Level: 100%</div></center>
</div>
</div>
I am probably missing something extremely simple and easy to fix, but I cannot for the life of me figure out what.
So my problem was I was running the code too early.
What I did to fix it was I made a new function called handler
, which I put calls to do things that I needed to do on page load.
Function handler()
checkBattery
... ETC ...
End Function
And in the body of my script I used
<body onLoad="VBScript:handler()">