1

Temat: tworzenie koloru RGB

<script>
  function kolor()
  {
    var r = document.getElementById('r');
    var g = document.getElementById('g');
    var b = document.getElementById('b');
    var x = document.getElementById('x');
    //
    x.style.backgroundColor = "rgb("+r.value+","+g.value+","+b.value+")";
  }
</script>
<form>   
  r: <input type="number" id="r" value="50" onchange="kolor()">
  g: <input type="number" id="g" value="160" onchange="kolor()">
  b: <input type="number" id="b" value="110" onchange="kolor()">
  <br><br><input type="button" id="x" value="OK" style="width: 200px" onclick="kolor()">
</form>

2

Odp: tworzenie koloru RGB

<script>
  function kolor()
  {
    var r = document.getElementById('r');
    var g = document.getElementById('g');
    var b = document.getElementById('b');
    var x = document.getElementById('x');
    //
    x.style.backgroundColor = "rgb("+r.value+","+g.value+","+b.value+")";
  }
</script>
<form>   
  r: <input type="number" id="r" value="50" onchange="kolor()">
  g: <input type="number" id="g" value="160" onchange="kolor()">
  b: <input type="number" id="b" value="110" onchange="kolor()">
  <br><br><input type="button" id="x" value="OK" style="width: 200px" onclick="kolor()">
</form>