title: pass a variable from a radio button
body: <p>I am attempting to pass the variable from a radio button to a variable in a javascript link. I am not able to get the variable 'testVar', which is in the for loop checking for the checked radio button, passed to the  link. I am stumped and this is the complete code:</p>
  
  <pre><code> &lt;form&gt;
      &lt;label&gt;Priority 1&lt;/label&gt;
      &lt;input type="radio" id="priority" name="priorityN" onclick="getResults();" value="prior1"  /&gt;
      &lt;label&gt;Priority 2&lt;/label&gt;
      &lt;input type="radio" id="priority" name="priorityN" onclick="getResults();" value="prior2"  /&gt;
  &lt;/form&gt;
  
  &lt;br /&gt;&lt;br /&gt;
  
  &lt;div id="myLink"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  
  var testVar = '';
  
  function getResults() {
  var radios = document.getElementsByName("priorityN");
  
  for (var i = 0; i &lt; radios.length; i++) {       
      if (radios[i].checked) {
          testVar = (radios[i].value);
      //  alert(radios[i].value);
          break;
      }
  }
  }
  
  document.getElementById("myLink").innerHTML = '&lt;a href=\"' + 'www.example.com?pri=' + testVar + '\" onclick=\"$(this).modal({width:880, height:460}).open(); return false;\" &gt;' + 'My Modal Link' + "&lt;/a&gt;";
  
  &lt;/script&gt;
  </code></pre>