Enable button if something change

I have a simple html

<input type=checkbox name="email" />
<input type=checkbox name="social_network" />
<button onclick="save_options();this.disabled=true;"onload="this.disabled=true;">Save</button>

I need the button enabled if I check one of the check boxes and disabled when I click itself. I can do this in Jquery pretty easily, but in javascript. So I try some code like Below and it doesn’t work. Any ideas?

document.getElementsByTagName("input").onChange(function(){
	document.getElementsByTagName("button").enabled = true;
});

A good start, but you need to check if the checkboxes are checked or not. Also, getElementsByTagName returns a NodeList of matched elements, so you have to either loop through them or select a specific one using square brackets.

var checkboxes = [document.getElementsByName('email')[0], document.getElementsByName('social_network')[0]],
button = document.getElementsByTagName('button')[0];
for (var i = 0; i < 2; i++) {
  checkboxes[i].onchange = function () {
    button.disabled = (checkboxes[0].checked || checkboxes[1].checked);
  }
  button.onclick = function() {
    checkboxes[0].checked = checkboxes[1].checked = false;
    this.disabled = true;
  }
}

Make sure this is all executed after the DOM has loaded (e.g. by placing it before the </body> tag).

Thanks Raffles.