In addition to the above, I think document.getElementById('bar').value=i; is suspect and that you mean
i = document.getElementById('bar').value;
Really don't know what window.setInterval("animate()",2000); is doing to help things so I removed it for this simplified version:
Code:
<!DOCTYPE html>
<html><head>
<script>
function animate()
{
i = document.getElementById('bar').value;
if (i == 0)
{
document.getElementById('pic').src = "http://www.XXX/BC_Webserver/Image/MTU 2.5MVA.gif";
}else{
document.getElementById('pic').src = "http://www.XXX/BC_Webserver/Image/3516.gif";
}
}
</script>
</head>
<body onload="animate();">
<input type=button onclick="document.getElementById('bar').value=1;" value="on">
<input type=button onclick="document.getElementById('bar').value=0;" value="off">
<input type=button onclick="animate()" value="animate">
<input type="text" id="bar" value="" width=30 height=30>
<img src="" alt="" id="pic" width=300 height=234> <!-- // update scr id with value from pic?-->
</body>
</html>