Код: Выделить всё
window.onload = init;
window.onload = myFunction;
function init() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "white";
ctx.fillRect(20, 20, 10, 60);
ctx.fillRect(70, 20, 10, 60);
ctx.fillRect(120, 20, 10, 60);
ctx.fillRect(170, 20, 10, 60);
}
function changeColor() {
var eID = document.getElementById("colors");
var colorVal = eID.options[eID.selectedIndex].value;
var colortxt = eID.options[eID.selectedIndex].text;
document.getElementById('colorDiv').style.background = colortxt;
}Код: Выделить всё
Black
Brown
Red
orange
Yellow
Blue
Violet
Grey
Подробнее здесь: https://stackoverflow.com/questions/337 ... onchange-e