Ok so I can't post comments yet but I've run into a similar problem before.
Without any additional code I can make an assumption that x is the calculated value and it is a number. It is invalid css to insert just a number into left thus you must append a unit to it before assign it to the property:
document.getElementById("block").style.left = x + 'px';
If that fixes your problem, then great! Otherwise please post how you calculate x between var x;
to the assignment of x.