Javascript - Change BG Color with Radio Buttons


SUBMITTED BY: Guest

DATE: Aug. 2, 2013, 7:25 p.m.

FORMAT: JavaScript

SIZE: 651 Bytes

HITS: 1294

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script>
  6. function changeBG(color) {
  7. document.body.style.backgroundColor = color;
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <input type="radio" name="bgcolor" value="red" onclick="changeBG('Red');"">Red<br />
  13. <input type="radio" name="bgcolor" value="blue" onclick="changeBG('Blue');">Blue<br />
  14. <input type="radio" name="bgcolor" value="green" onclick="changeBG('Green');">Green<br />
  15. <input type="radio" name="bgcolor" value="yellow" onclick="changeBG('Yellow');">Yellow
  16. </body>
  17. </html>

comments powered by Disqus