select.html

  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <meta charset="UTF-8">
  4. <title>Select</title>
  5. function cambiarColor(select) {
  6. //alert(select.value);
  7. document.body.style.backgroundColor = select.value;
  8. }
  9. </script>
  10. </head>
  11. <h1>Select</h1>
  12. <p>
  13. <label>Color de fondo:</label>
  14. <select onchange="cambiarColor(this)">
  15. <optgroup label="Primarios">
  16. <option value="#FF0000">Rojo</option>
  17. <option value="#00FF00">Verde</option>
  18. <option value="#0000FF">Azul</option>
  19. <optgroup label="Complementarios">
  20. <option value="#FFFF00">Amarillo</option>
  21. <option value="#FF00FF">Magenta</option>
  22. <option value="#00FFFF">Cian</option>
  23. </select>
  24. </p>
  25. </body>
  26. </html>

Proinf.net