title: Getting value of multiple radio buttons groups javascript
body: <p>I am currently working on a form which has to process a data filled in a by a client. It has a few radio groups and I'd like to get the value of it when it's changed. </p>
  
  <pre><code>&lt;input type="radio" name="domain" value="no"&gt;
  &lt;input type="radio" name="domain" value="yes"&gt;
  
  &lt;input type="radio" name="hosting" value="no"&gt;
  &lt;input type="radio" name="hosting" value="yes"&gt;
  </code></pre>
  
  <p>I found a function like it somewhere, but it does not work the way I want. </p>
  
  <pre><code>    function getSelectedValueFor(name) {
          alert(document.getElementsByTagName(name).length);
          for (var i = 0; i &lt;
              document.getElementsByTagName(name).length; i++) {
              var input = document.getElementsByTagName(name)[i];
                  if (input.type == "radio" &amp;&amp; input.checked) {
                      return input.value;
                  }
          }
          return null;
  }
  </code></pre>
  
  <p>It basically should work like this, and work for "getSelectedValueFor()" should be reusable:</p>
  
  <pre><code>$('input[name="hosting"]').change(function(){
      var x = getSelectedValueFor("hosting");
      console.log(x + " test");
      if(x == "yes") { $('#hosting').slideDown(); }
      else if(x == "yes") { $('#hosting').slideUp(); }
      return;
  });
  </code></pre>
  
  <p>Is there anyone who can help me out? All help is appreciated.</p>