1

beneath is my code, i want to retrieve the variable "state" from a uploaded text file. The text file can contain "ON" or "OFF". I wan't that it displays the onlineimage when it's "ON" and the offlineimage when it's "OFF".

Link to text file: https://dl.dropboxusercontent.com/s/qgmhqd7pesuh0dq/statefile.txt?dl=1&token_hash=AAGifdOynGE-pnTP8DuqzWBgY-Gv3aQ8PEXE2NhYP471ew

Please be detailed cuz i'm new to html and javascript.

<!DOCTYPE html>
<html>
<body>

<img id="demo" src="" alt="Loading image...">

<script>
var onlineimage="http://i.epvpimg.com/j2A3d.png";
var offlineimage="http://i.epvpimg.com/YYkfc.jpg"
var state=true;

myFunction()
function myFunction()
{
var x="";
if (state)
  {
  x=onlineimage;
  }
else
  {
  x=offlineimage;
  }
document.getElementById("demo").src=x;
}

</script>

</body>
</html>

0 Answers0