<div id='colors'>
<input type='button' value='red' onclick="saveColor('red')">
<input type='button' value='green' onclick="saveColor('green')">
<input type='button' value='blue' onclick="saveColor('blue')">
</div>
<input type='button' onclick='change()' value='change'>
<input type='button' value='скрыть\показать' onclick='b()'>
<div id='sqare' style="height:100px;width:100px;background:red"><div>
<input type='text' style='display:none' id='text'>
<script>
function saveColor(color) {
document.getElementById('text').value = color
}
function change() {
document.getElementById('sqare').style.background = document.getElementById('text').value
}
function b() {
with(document.getElementById('colors').style) {
display == 'none' ? display = 'block' : display = 'none'
}
}
</script>
Правда это полный гавнокод(very, very, very bad code), используйте на свою совесть. Мне просто в голову другие мысли не лезут =/