title: set a radio button value based on option select using Javascript only
body: <p>I am trying to set a radio button based on selecting an option in a select box.</p>
  
  <p>For example, There are 5 select options available, If I select the first option, first radio button should be checked. Likewise for the rest of the things. I am working only with Javascript.</p>
  
  <p>I have tried the below code.</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;JS Test&lt;/title&gt;
      &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
      &lt;meta charset="utf-8"&gt;
    &lt;/head&gt;
    &lt;body&gt;
          &lt;div&gt;&lt;/div&gt;
          &lt;div&gt;
              &lt;form name="myform" action=""&gt;
                  &lt;label for="name"&gt;Name&lt;/label&gt;
                      &lt;input type="text" name="name"&gt;&lt;/input&gt;
                  &lt;br&gt;    
                      &lt;label for="select_value" onchange="myFunction()"&gt;Select Number&lt;/label&gt;
                      &lt;select name="select_value"&gt;
                          &lt;option value="1"&gt;1&lt;/option&gt;
                          &lt;option value="2"&gt;2&lt;/option&gt;
                          &lt;option value="3"&gt;3&lt;/option&gt;
                          &lt;option value="4"&gt;4&lt;/option&gt;
                          &lt;option value="5"&gt;5&lt;/option&gt;
                      &lt;/select&gt;
                  &lt;br&gt;
                      &lt;label for="radio_value"&gt;Select Position&lt;/label&gt;
                      &lt;input type="radio" name="radio_value" value="First"&gt;First&lt;/input&gt;
                      &lt;input type="radio" name="radio_value" value="Second"&gt;Second&lt;/input&gt;
                      &lt;input type="radio" name="radio_value" value="Third"&gt;Third&lt;/input&gt;
                      &lt;input type="radio" name="radio_value" value="Fourth"&gt;Fourth&lt;/input&gt;
                      &lt;input type="radio" name="radio_value" value="Fifth"&gt;Fifth&lt;/input&gt;
                  &lt;br&gt;
                      &lt;input type="submit" name="form_submit" value="Submit"&gt;&lt;/input&gt;
              &lt;/form&gt;
          &lt;/div&gt;
          &lt;script type="text/javascript"&gt;
          function myFunction() {
                  var x = document.getElementsByName("select_value").value;
                  document.getElementsByName('radio_value')[x].checked=true;
          }
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p><a href="http://jsfiddle.net/o9jxf2zz/1/" rel="nofollow">JSFIDDLE</a></p>