I'm setting up a new server using a PLC. With this this server I must turn on/off the lights. At the moment I use a function to refresh the values coming from the PLC so the main page doesn't have to refresh constantly. I can already show a 1 or a 0 using an id and a label. I want to show a picture instead of a 1 or a 0.
I tried first with a 1 or a 0 instead of an image to simplify and see if that works. I thought by using L_Software and check if the value is 1 or 0 to return a 1 or 0.
<label id="test"> dummy </label>
<br>
<label id="L_Refter">:="DB1 Lichten".Refter:</label>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$.ajaxSetup({ cache: false });
setInterval(function() {
$.getJSON("DataLichten.html", function(result){
$('#L_Software').text(result.Software)
$('#L_Refter').text(result.Refter)
});
},1000);
});
function lamp(waarde)
{
if (waarde=="1")
{
return 1;
}
if (waarde=="0")
{
return 0;
}
}
document.getElementById("test").innerHTML = lamp(L_Software);
</script>
I expect to show a 1 or a 0 instead of dummy. And later on make the 1 or 0 an image.