Podría ser var a = document.getElementById(...) y luego a.style.backgroundColor. O, si x tiene simpre valores consecutivos (0, 1, 2, 3, 4...) yo lo haría con un array. Por ejemplo:
Código javascript
:
Ver originalvar colores = ["Red", "Black", "White", "Green"];
document.getElementById(...).style.backgroundColor = colores[x];