Chcę zmienić kolor tła, poprzez kliknięcie na radio button:
function changeColor()
{
if (document.tlo.kolor[0].checked) document.style.background='red';
if (document.tlo.kolor[1].checked) document.style.background='yellow';
if (document.tlo.kolor[2].checked) document.style.background='green';
}
document.write('<form name="tlo">');
document.write('<input type="radio" name="kolor" value="r" onClick="changeColor()"> Czerwony<br>');
document.write('<input type="radio" name="kolor" value="y" onClick="changeColor()"> Żółty<br>');
document.write('<input type="radio" name="kolor" value="g" onClick="changeColor()"> Zielony<br>');
document.write('</form>');
I wyskakuje błąd, że document.style jest pusty lub nie jest obiektem. O co chodzi?