Does this help you?
Code:
<script type='text/javascript'>
function change_bg(hex, id){
document.getElementById(id).style.background="#"+hex;
}
</script>
<button onClick="change_bg('0000A5','table_d');">Color1</button> <button onClick="change_bg('7272A3','table_d');">Color2</button>
<button onClick="change_bg('FF967C','table_d');">Color3</button>
<table width="500" height="500" id="table_d"><tr><td></td></tr></table>
Now, all you need to do is add buttons, you should do it like this(the onClick).
Code:
cahnge_bg('hex_code_without_#','id')
Bookmarks