<div id='state' style='background: #555555; height: 20px; width: 0;'>
</div>
<script type='text/javascript'>
var speed = +prompt("Введите скорость:") / 100,
distance = +prompt("Введите расстояние:"),
e = 0;
setTimeout(function () {
e += speed;
document.getElementById("state").style.width = Math.round(e) + "px";
if (e <= distance)
setTimeout(arguments.callee, 10);
}, 10);
</script>